Rails Trace

What code runs when you request a page from a Ruby on Rails application?

Here is an annotated trace showing every method call within Rails and its dependencies. It is for an example application that loads a blog post from the database and renders a page containing the post's title.

Scroll to see the trace

Our Template

Templates are written in a templating language such as ERB or HAML so can't be called like a normal Ruby method. Instead, the first time a template is used Rails compiles it into a method. Here Rails has already compiled this view into a method named after our template in ActionView::CompiledTemplates that we can call.

Rails modifies the application trace so it appears to be executing the corresponding line in your view template rather than the compiled method. This makes debugging errors in your view templates easier.

Created by Chris Zetter in a tribute to Rails and its many contributors.

Read out more about how the trace was made.

You can see the code that powers this page and suggest resources to link to on GitHub.