Suppose I have an ActiveAdmin model with two scopes like so:
ActiveAdmin.register Book do
scope :all, default: true
scope :smith #all books by author 'smith'
index do
column :title
column :published_year
column :author
end
end
I don't want/need the 'author' column when the user has selected the 'smith' scope.
So is there a way to get access to the current scope and only show the author column in one of the scopes? I suppose for this example I could use a custom view and check the actual content of the data but I am hoping there is an easier and better way.
you can try something like that
index do
column :title
column :published_year
column :author unless params['scope'] == 'smith'
end
You also have access to the @current_scope object, and you can do @current_scope.scope_method to get the underlying scope method
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With