These tips may help those of you who are relatively new to Rails, or maybe even if you’re not.
Common tips and tricks
- Look at the URL path (e.g.
/users/100685/edit). Can the action and main view file be determined from CRUD/REST conventions?
- Look up the path in routes.rb, or even more useful, run
Finding a controller and action responsible for a given page
- In development go to your server’s output, and clear the screen (
Ctrl+L, for Linux,
Cmd-Kfor OS X)
- Refresh the web page
- Back to the server’s output, scroll to the top of the output. About the second
line of non-blank log output, you should see something like:
Processing by UserseController#edit as HTML. That’s the controller (
UsersController) and action (
Finding a view file for a given page
- If in development, look at the server log. If it is too noisy, use
tail -f log/development | grep Renderedto cut out the noise.
- If in development, add the
rails_view_annotatorgem to your Gemfile, and look at the DOM or HTML source. It should have HTML comments identifying the view partials responsible for their generated HTML.