I have the following routing layout:
map.resources :users do |user|
user.resources :blog, :controller => :user_blog_controller,
:name_prefix => 'user_'
The trouble is that I cannot user blog_path() without an argument.
blogs_path() does not work either and it would be ugly/inconsistent if
it did anyway.
Couldn't blog_path with no arguments just return /blog and not try to
I could just do user.resources :blog_entries, but it doesn't give as
nice URLs. Besides, I have the same problem with user.resources
Maybe you wanted
“user.resource” (singular) instead of “user.resources”? Read the API documentation to know the difference.
My user blog contains the user's blog entries, so IT IS plural in
semantics. It's just that I don't want the URL to be
/user/123/blog_entries but /user/123/blog instead. Unfortunately,
"blog" is singular.
P.S. Thanks for recommending to read the documentation. I've found the
documentation as such to be a very useful thing indeed.
It looks like your going have to map everything the old fashion way.
You can't use a singular word with a resource like that because
map.resources wants to define singular and plural named routes like
blog_path(id) == /blogs/id and blogs_path == /blogs.
Does it suit your needs? It’s semantic, it’s nice … and it works.
No problem. But next time pay more attention to the documentation: however obscure this parameter may be, it’s still documented.