How to change a route name rails 4
path
option along with resource must help.
resources :posts, :path => 'blogs' do
resources :comments
end
This will change all /posts
and /post
to /blogs/
and /blog
.
If you want to change your route's helper methods such as posts_path
to blogs_path
and new_post_path
to new_blog_path
etc, you can change it with as
tag.
resources :posts, :path => 'blogs', :as => 'blogs' do
resources :comments
end
Or yet better, you can specify the controller and route blogs
directly as:
resources :blogs, controller: 'posts' do
resources :comments
end
This is the awesomeness of Rails! :)