【问题标题】:Specifying parent controller in rails_admin results in deprecation warning在 rails_admin 中指定父控制器会导致弃用警告
【发布时间】:2020-08-07 17:08:15
【问题描述】:

我在我的 rails 6 项目中注意到,将以下内容添加到 config/initializers/rails_admin.rb 会导致弃用警告:

RailsAdmin.config do |config|
  config.parent_controller = ApplicationController.to_s

  # ...

警告:

DEPRECATION WARNING: Initialization autoloaded the constants ApplicationHelper, AboutHelper, GroupHelper, MapHelper, DeviseHelper, ActionText::ContentHelper, and ActionText::TagHelper.

Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.

Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload ApplicationHelper, for example,
the expected changes won't be reflected in that stale Module object.

These autoloaded constants have been unloaded.

Please, check the "Autoloading and Reloading Constants" guide for solutions.
 (called from <main> at /opt/app/config/environment.rb:5)

一种解决方法是简单地使用"ApplicationController" 而不是ApplicationController.to_s,但是有没有办法在没有此弃用警告的情况下执行后一种方法?

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-6 rails-admin


    【解决方案1】:

    是的,你是对的

    # Which class should be used for the controllers
      config.parent_controller = '::ApplicationAdminController'
    

    这里是库中的问题issue_link

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-24
      • 1970-01-01
      • 1970-01-01
      • 2017-07-12
      • 1970-01-01
      • 1970-01-01
      • 2017-11-03
      相关资源
      最近更新 更多