Changing default REST routes in Rails 3

Posted by Vincent on Stack Overflow See other posts from Stack Overflow or by Vincent
Published on 2011-03-14T00:07:23Z Indexed on 2011/03/14 0:09 UTC
Read the original article Hit count: 176

Filed under:

I need to add one parameter to the default REST route for the show action for SEO purposes:

resources :neighborhoods, :only => [:index, :show]

neighborhood_url(neighborhood) # => /neighborhoods/lower-east-side

I want something like the following:

neighborhood_url(city, neighborhood) # => /neighborhoods/manhattan/lower-east-side

What would be the easiest way to do this without using nested routes and without breaking Rails REST conventions?

© Stack Overflow or respective owner

Related posts about ruby-on-rails-3