xtioqg
Last Updated: February 25, 2016
·
3.427K
· demiazz
71e9761dce27485eb3ced22ed60f59d1

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

Say Thanks
Respond

6 Responses
Add your response

2667

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 ·
2681
71e9761dce27485eb3ced22ed60f59d1

@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 ·
4080

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

over 1 year ago ·
6417
71e9761dce27485eb3ced22ed60f59d1

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

over 1 year ago ·
10606
326a57576b4221a13f80a5588b7d8a2b

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

over 1 year ago ·
11620
902c57f4b5f63db9c91dffb57b090654

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 ·