ActiveAdmin: batch actions for different scopes
If needed show some batch actions only with different scopes, we can use this dirty trick:
batch_action :action_name, if: proc { @current_scope.scope_method == :needed_scope } do |selection|
do_something
end
If you know more right and elegance method -tell me, please. (=
Written by Alexey Plutalov
Related protips
6 Responses
I can't make it work with @currentscope.scopemethod, I am using activeadmin 0.5.0, which version are you using?
Thanks!
@jbala87 Hm. I'm using 0.5.0 too. Look at this example. https://gist.github.com/4343570 and try bind pry in proc.
I haven't been able to get this to work either. @current_scope is coming back as nil.
It's really strange... This is code work for me. SCRATCH
@current_scope works for me with ActiveAdmin 0.6 and rails 4.
I was having the same problem. I solved it by specifing a default scope in the admin model, like this
scope :needed_scope, default: true
Rails 3.2.16 and last activeadmin master (https://github.com/gregbell/active_admin/tree/51792c7924372fc0c8789bc849f82e09041e1218)