Renaming resources in Rails

If you’ve got a long model name and it’s ruining your URL paths and making them look terrible you can modify your config/routes.rb file to rename the path and helper routes of the model. The slash is in there to prevent WordPress changing the owners into a smiley face, thanks WordPress.

resources :gyms do
  resources :\owners
  resources :lessons do
   resources :student_lessons, path: "class", as: "class"
  end
end
Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

You May Also Like

Sparks

I’ve lost mine. I’m not feeling my job at the moment at all, or web design in general.…