Sunday, August 15, 2010

[Rails] Singular resources namespaced by its slug (Routing)

Hi,

I have the followed Rails 3 routes:

Hello::Application.routes.draw do
resources :blogs do
resources :articles do
resources :comments
end
end
end

By raking them, we can find (for instance):

GET /blogs/:blog_id/articles(.:format) {:action=>"index",
:controller=>"articles"}

Because every routes begin with the same root path (*/blogs*), I would
like to shorten addresses by removing it (when :blog_id is given).

In this why, I could have thoses routes (I think it's more DRY):

GET /:blog_id/articles(.:format) {:action=>"index",
:controller=>"articles"}

According to you, what kind of change I should make over my current
routes configuration?

Thanks.
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate