- refactoring routes
get "/", controller: "movies", action: "index"
- more shorthand syntax for a route
get "/" => "movies#index"
- we can shorten this even further for the root because there is only 1 path:
root "movies#index"
"rails routes" command shows all defined routes
we can name routes with "as:"
get "/movies/:id" => "movies#show", as: :details
- we can then access this specific route with an argument:
details_path(42) --> "/movies/42"
- Using route names reduces redundancy when updating URL names! Always refer to URLs using route names from now on
Top comments (0)