gregbell/active_admin — Issue #720: How to iterate columns of a resource?
Author: kristianmandrup
Created: 2011-11-04 14:37:21+00:00
State: open

I would like to iterate the columns of a given resource and then for each column determine if it should be displayed or not depending on some Access Control logic for the Admin user (using CanCan).
How would I go about this?

I looked at `ActiveAdmin::Views::TableFor`, but it looks like the `@columns` and `@collection` are not exposed but used only internally!?

I have found this example:

# For example, if you were using CanCan:
#
# index do
# column :title, :sortable => false
# if can? :manage, Post
# column :some_secret_data
# end
# end

But would like a more generic approach, sth like:

index do
column_names.each do |name|
if can? ":read_attribute_#{name}", Post
column name
end
end
end

Could you add support for this, or where would I need to extend/monkey patch to add this functionality?