我有 rails 应用程序,它有多个引擎users
,companies
等等。
#main_app: /config/routes.rb
Rails.application.routes.draw do
mount RailsAdmin::Engine, at: 'admin', as: 'rails_admin'
mount Users::Engine, at: "users", as: "users"
mount Companies::Engine, at: "companies", as: "companies"
...
end
我想rails_admin
从 main_app 以及每个引擎进行配置。
#main_app: /config/initializers/rails_admin.rb
RailsAdmin.config do |config|
config.authorize_with :cancan
...
end
在这种情况下,一切正常:
$ rake routes
...
Routes for RailsAdmin::Engine:
dashboard GET / rails_admin/main#dashboard
index GET|POST /:model_name(.:format) rails_admin/main#index
new GET|POST /:model_name/new(.:format) rails_admin/main#new
export GET|POST /:model_name/export(.:format) rails_admin/main#export
bulk_delete POST|DELETE /:model_name/bulk_delete(.:format) rails_admin/main#bulk_delete
history_index GET /:model_name/history(.:format) rails_admin/main#history_index
bulk_action POST /:model_name/bulk_action(.:format) rails_admin/main#bulk_action
show GET /:model_name/:id(.:format) rails_admin/main#show
edit GET|PUT /:model_name/:id/edit(.:format) rails_admin/main#edit
delete GET|DELETE /:model_name/:id/delete(.:format) rails_admin/main#delete
history_show GET /:model_name/:id/history(.:format) rails_admin/main#history_show
show_in_app GET /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app
但是当我尝试从引擎发送其他配置时:
#users_engine: /config/initializers/rails_admin.rb
RailsAdmin.config do |config|
config.excluded_models << "Users::Phones::ConfirmAttempt"
config.actions do
new do
except ["Users::User"]
end
end
...
end
我的路线有些奇怪,我无法rails_admin
通过浏览器访问:
$ rake routes
...
Routes for RailsAdmin::Engine:
new GET|POST /:model_name/new(.:format) rails_admin/main#new
bulk_action POST /:model_name/bulk_action(.:format) rails_admin/main#bulk_action
有人可以解释一下,如何解决这个问题。或者 mb 另一种方式,我如何能够rails_admin
从每个引擎发送配置?