spree/spree — Issue #735: Namespace route mounting
Author: radar
Created: 2011-11-06 13:24:22+00:00
State: open

Within the `namespace` branch, we have each engine separate. To now include the engines into an application, you must do something messy like this in the application's `config/routes.rb` file:

Rails.application.routes.draw do
# Your routes go here
mount Spree::Promo::Engine, :at => "/"
mount Spree::Auth::Engine, :at => "/"
mount Spree::Core::Engine, :at => "/"
end

I think it would be better if you did this:

Rails.application.routes.draw do
# Your routes go here
spree
end

That would then mount *all* parts of Spree by default at the root route. You can opt-out of things by passing an `:except` option to this method.

### Controller specification

This method could also then take a `:controllers` option that would be used to customise the routing for the engine. I would imagine it would look something like this:

spree :controllers => { :core => { :products => "products" } }

This would then tell Spree to use the application's `ProductsController` rather than `Spree::ProductsController`.

### Path specification

There may be a case where people would want the engines to be mounted at a different path. The `spree` method could take an option called `:path` that would define a path prefix for all the engines:

spree :path => "shop"

Or alternatively, we could call this option `:paths` and have users specify it like this:

spree :paths => { :core => "shop" }

WDYT, @schof, @BDQ, @joneslee85?