1

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 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

1 Comment

Is this the cleaner way to do is? It should be another way. Anyway, thanks for this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.