简体   繁体   English

Rails::Engine 路由未在生产环境中加载

[英]Rails::Engine routes not being loaded in production environment

I'm having a really strange problem whereby my routes are working fine in development mode but not in production.我遇到了一个非常奇怪的问题,我的路线在开发模式下运行良好,但在生产模式下运行不正常。

The majority of my app is contained within an engine, which is loaded into the main application, and the routes file the main app starts like this...我的大部分应用程序都包含在一个引擎中,该引擎已加载到主应用程序中,而主应用程序的路由文件是这样启动的……

SandersteadParish::Application.routes.draw do
  mount Cms::Engine => "/cms"

The first few line of my routes file in the engine look like this...引擎中我的路由文件的前几行看起来像这样......

Cms::Engine.routes.draw do
  scope '(groups/:group_id)' do
  resources :pages do
    resources :widgets
      collection do
      post :layout, :add_panel, :split_panel
    end
  end

If I run RAILS_ENV=development rails server, the routes work fine, but if I run RAILS_ENV=production, they don't get loaded.如果我运行 RAILS_ENV=development rails server,路由工作正常,但如果我运行 RAILS_ENV=production,它们就不会被加载。

when you add add engine is "isolated" by default this means all it routes needs to be accessed with the engine scope for example Cms.pages_path you can find more info here http://edgeguides.rubyonrails.org/engines.html#routes当您添加添加引擎时,默认情况下“隔离”这意味着它的所有路由都需要使用引擎 scope 访问,例如Cms.pages_path您可以在此处找到更多信息http://edgeguides.rubyonrails.org/engines.html#routes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM