Easily rename all routes for a Rails REST resource
I needed to generate a scaffold in Rails, but the name I wanted to call it was a Rails protected word. :( So, I called it something else and just figured I'd rewrite all my named routes so the URL would still appear to use the name I originally wanted to use. I'm still a Rails noobie, so I thought I'd share the quick tip I learned on renaming all routes for a single REST resource in one line:
resources :posts, :path => "entries"
That will turn this (and every other path for posts) from something like this:
posts GET /posts(.:format) posts#index
into this:
entries GET /entries(.:format) posts#index
Simple!
Written by Jon Thomas
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#