ActiveAdmin Collection action on filtered data

I have a custom collection action on an index page and I want to access the filtered data inside this action. How can i do this? Can I get a collection? or maybe filter options?

  collection_action :do_something do
    # call some async process
    redirect_to :action => :index, :notice => "started working!"
  end

  action_item :only => :index do
    link_to('DO WORK', do_something_admin_game_stats_path)
  end

      

+2


source to share


1 answer


You should pass parameters scope

and filter

as parameters in your action link_to

and then use them scoped_collection

in your collection_action

.

link_to "DO WORK", do_something_admin_game_stats_path(param.slice(:scope, :filter))

      



I'm not sure if the filter is the correct param key, but the principle should be the same. If for some reason you cannot access the params

in action link, try it controller.params

or if you are really desperate controller.send(:params)

. From head to toe, I'm not sure if the parameters are publicly available in the view from my head.

+3


source







All Articles