27

The intention is to create a subdomain to hold all the administrative function (CRUD) and the name of the subdomain is "admin". The set of controllers responsible are also organized under the namespace of "admin", i.e. the controllers are under the app/controllers/admin directory.

Ideally, the following routes should be

admin.mydomain.com/products/     
admin.mydomain.com/products/new ...

and not

admin.mydomain.com/admin/products/
admin.mydomain.com/admin/products/new ...

I would like to keep the helpers with the "admin" prefix such as:

new_admin_product
edit_admin_product

My current routing code works and it is as below:

constraints :subdomain => "admin" do
  scope :module => "admin", :as => "admin" do
    resources :players
  end
end

Is this the right approach?

Ronnie Liew
  • 18,220
  • 14
  • 46
  • 50
  • As I can see, this brakes all other routing for the resource `:players` if you use it again without the namespace. I'm looking for a workaround for this. – Cristian Oct 16 '12 at 11:12
  • This is my mistake, I forgot the `:as => "admin"` which actually doesn't let overrides – Cristian Oct 16 '12 at 11:15

1 Answers1

20

Yes, this will give you precisely what you're after in the neatest fashion I know possible.

Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261