Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How the customize or change the route paths in rails?

For example consider the following output from rake routes:-
posts GET /posts(.:format) {:action=>"index", :controller=>"posts"}
posts POST /posts(.:format) {:action=>"create", :controller=>"posts"}
*new_post* GET /posts/new(.:format) {:action=>"new", :controller=>"posts"}
*edit_post* GET /posts/:id/edit(.:format) {:action=>"edit", :controller=>"posts"}
post GET /posts/:id(.:format) {:action=>"show", :controller=>"posts"}

If i want to change the path name of "new_post" to "create_post" how do I do it ??

like image 943
Hemanth Avatar asked Oct 28 '25 15:10

Hemanth


1 Answers

match '/posts/new' => 'posts#new', :as => :create_post in your routes should work!

like image 76
satya on rails Avatar answered Oct 30 '25 06:10

satya on rails



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!