views:

69

answers:

1

Hi!

Is it possible to define a namespace parameter when defining my routes, like this:

resource :account, :namespace => :account do
    resources :comments
end

So /account/comment calls Account::CommentsController instead of just CommentsController. Just as a note, the :namespace-option above does NOT seem to work.

I can of course just add :controller => 'account/comments' to the comments resources, but having a lot of nested resources, this is not very DRY.

Is there better way?

Thanks guys - you rock!

+1  A: 

Okay, after some digging around I seem to have found a solution:

resource :account, :controller => 'account' do
    scope :module => 'account' do
        resources :comments
        ...
    end
end

This results in:

/account/comments being linked to Account::CommentsController while still being able to acccess the regular CRUD-methods using /account

Mattias