Engine routes in Application Controller

前端 未结 5 2146
予麋鹿
予麋鹿 2020-12-29 10:20

I have a before_filter hook in my main app\'s application controller that does something like: (It doesn\'t just put a link in the flash, there is a message, but it isn\'t r

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-29 10:59

    You can keep the isolate_namespace. In your engine routes.rb

    MyEngine::Engine.routes.draw do
      ...
      root to: "something#index"
    end
    
    Rails.application.routes.draw do
      get "something", to: "my_engine/something#index"
    end
    

    And then in the main app routes.rb

    Rails.application.routes.draw do
    
      mount MyEngine::Engine => "/anything_you_want"
    
      root to: "main#index"
    end
    

    This way you can choose what routes you want to expose (and which you do not)

提交回复
热议问题