How often does Rails reload the routes.rb file?
How do you set the routing for the empty URL, which is usually the home or landing page for a site?
If there are multiple routes that could match a given URL, how does Rails choose?
How do you tell Rails to just “grab the rest of this URL and put it into a parameter”?
How many routes does a single plain map.resources
call create?
What’s the fastest way to see Rails’ list of routes?
How do you add a fragment identifier to the end of a URL
created with url_for
?
In development mode, Rails checks to see if the routes.rb file has changed and reloads it if it has. In production mode, Rails doesn’t check, and you’ll need to stop and restart the server to update routes.
The map.root
method lets you tell Rails how to handle requests
aimed at the top of your site. You’ll also need to delete or
rename public/index.html.
Rails always applies the first route that matches a given URL, starting from the top of routes.rb.
Globbing, using an asterisk, lets you halt further processing of the URL and send it along to the controller method as a parameter.
map.resources
creates an astounding 14 routes, representing seven
different methods built on REST, with and without a format.
The rake routes
command will show you the list of routes Rails
believes it has.
The :anchor
parameter lets you specify a fragment identifier,
which comes after # at the end of the URL.