Mountable Engine Host Root Override

I am writing a mounted Rails 3 Engine, and I combine my routes with the host application. However, host application routes take precedence over my routes. Is there a way to redefine host application routes (in particular, the root route)?

Here my engine moves to my_enging/config/routes.rb:

MyEngine::Engine.routes.draw do
 root :to => "home#index"
end

# Mount engine routes to host application
Rails.application.routes.draw do
  mount MyEngine::Engine, :at => "/"
end

And here are the results rake routes, with the host root at the top:

root  / welcome#index
my_engine  / MyEngine::Engine
root  / home#index

Spree is the one stone that does this, but I could not find how they are implemented.

+5
source share
1 answer

- , , , , . , , :

Spree - eval_block, .

root to:, , . . , , , !

W12::Engine.routes.draw do
  root to: 'details#index'
end

MyCarsApplication.routes.draw do
  mount Common::Engine => "/"
end

:

root / details#index

.

, .

0

All Articles