如何删除activeadmin批处理操作路由

时间:2014-02-12 13:34:14

标签: ruby-on-rails ruby-on-rails-3.2 routes activeadmin

使用Rails 3.2.12,active_admin 0.6.2 / 0.6.3,我在ActiveAdmin初始化程序中禁用了批处理操作:

config.batch_actions = false

但是,rake routes显示所有已注册的ActiveAdmin控制器的批处理操作路由:

$ rake routes | grep batch
            batch_action_admin_admin_users POST     /admin/admin_users/batch_action(.:format)                                               admin/admin_users#batch_action
                batch_action_admin_members POST     /admin/members/batch_action(.:format)                                                   admin/members#batch_action
           batch_action_admin_sales_agents POST     /admin/sales_agents/batch_action(.:format)                                              admin/sales_agents#batch_action
               batch_action_admin_comments POST     /admin/comments/batch_action(.:format)                                                  admin/comments#batch_action

如何删除这些路线?

我尝试使用以下内容修补this code

post :batch_action if config.batch_actions

但它不起作用。

编辑:下面的答案都可以说明问题。有一个PR fixing this

2 个答案:

答案 0 :(得分:0)

我已经分析了ActiveAdmin的来源。这是我found

def resource_routes(config)
  # Some code here...
  case config
  when ::ActiveAdmin::Resource
    resources config.resource_name.route_key, :only => config.defined_actions do
      member do
        config.member_actions.each &build_action
      end

      collection do
        config.collection_actions.each &build_action
        post :batch_action
      end
    end
  # Code continues..
end

ActiveAdmin根本就没有配置选项。它总是生成批次路线。

答案 1 :(得分:0)

在查看源代码here后,我发现适当的猴子补丁会使用config.batch_actions_enabled?