Last Updated: February 25, 2016
·
4.83K
· demiazz

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. (=

6 Responses
Add your response

I can't make it work with @currentscope.scopemethod, I am using activeadmin 0.5.0, which version are you using?
Thanks!

over 1 year ago ·

@jbala87 Hm. I'm using 0.5.0 too. Look at this example. https://gist.github.com/4343570 and try bind pry in proc.

over 1 year ago ·

I haven't been able to get this to work either. @current_scope is coming back as nil.

over 1 year ago ·

It's really strange... This is code work for me. SCRATCH

over 1 year ago ·

@current_scope works for me with ActiveAdmin 0.6 and rails 4.

over 1 year ago ·

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)

over 1 year ago ·