ActiveAdmin: batch select all pages

≯℡__Kan透↙ 提交于 2019-12-31 06:54:09

问题


Using activeadmin, is it possible to perform a batch action on ALL records of a particular Model, instead of the ones just selected on the current page?


回答1:


The default batch actions operate only on the selection from the current page. You'll have to define your own batch action that just ignores the selection and does the operation on all the records.

See http://activeadmin.info/docs/9-batch-actions.html for details - you need to add something like this:

ActiveAdmin.register MyModel do
    batch_action :my_action do |selection|
      collection = MyModel.all
      # ... and do something with the collection
    end
  end


来源:https://stackoverflow.com/questions/27159477/activeadmin-batch-select-all-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!