Beverly Nelson changelog.com/posts

Xray-rails reveals which files are being rendered in your view

When I pair with Railsbridge attendees or new developers, I often wish I had a visual way to let them see the connection between the files in the codebase and what’s rendered in the browser. Today Ruby 5 featured Xray and a number of friends contacted me about checking it out. In no time I knew I’d found the solution.

I gave it a test drive on one of the student apps and it took 5 minutes, at most, to get up and running.

Just drop this in your Gemfile:

group :development do
  gem 'xray-rails'
end

Bundle and delete the cached assets:

$ bundle && rm -rf tmp/cache/assets

Restart your app, visit it in your browser, and press cmd+shift+x

xray-rails

By far the best feature in Xray is the fact that it allows you to actually click on the overlay and go straight to the file or partial being rendered. It defaults to Sublime, which is easy for new users, but is simple enough to customize to another tool for seasoned pros.

Xray is great for:

  • Helping new Rails developers while pairing to get clearer understanding of views
  • Gaining quick insight into complex views
  • Debugging templates, partials, and backbone views

See Xray in action

Right now Xray is a tool for the Rails framework but there are plans to expand and make it available for any framework. You can check it out on Github.


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00