Modifying BaseController in rails ActiveAdmin gem

别说谁变了你拦得住时间么 提交于 2019-12-10 13:38:25

问题


I am using the ActiveAdmin gem in a rails app. If I wanted to add a new before filter that applies to all activeadmin gems, how would I do this? I imagine I could modify the BaseController in ActiveAdmin to achieve this, but what is the proper way to make this modification from within the rails app? Is there a way to duplicate and overwrite the BaseController?


回答1:


If I understand you , there is a special config for this

  # == Controller Filters
  #
  # You can add before, after and around filters to all of your
  # Active Admin resources from here.
  #
   config.before_filter do



   end

you can find it in initializers/active_admin.rb




回答2:


I did same thing by writing my code in config/initializers/active_admin.rb . Just check the line #enter code here

#Controller Filters

# You can add before, after and around filters to all of your

# Active Admin resources and pages from here.

Write down your code here same as described by Fivell



来源:https://stackoverflow.com/questions/13180005/modifying-basecontroller-in-rails-activeadmin-gem

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