Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the easiest way to find where a part of html is defined in the Rails partials and layouts?

I am working with a fairly large Rails application. I am new to the application and I don't know its structure very well. Sometimes when I browse it I notice something in the views I want to change. I then start to look for the file where a particular region is defined. Sometimes if I want to correct a specific text, I am able to find it quickly by searching for part of it. But sometimes I want to edit a region, which contains very generic words and also generic css classes, like .menu-wrapper, .header-menu etc.. How do you find out quickly in which layout or partial a particular region of a view is defined? The app uses Slim as a templating engine, if that's relevant.

like image 751
Alexander Popov Avatar asked Jan 26 '26 14:01

Alexander Popov


1 Answers

You can use xray-rails gem:

In your Gemfile:

group :development do
  gem 'xray-rails'
end

Then:

bundle && rm -rf tmp/cache/assets

restart your application and it is it. You can now access your layouts/templates/partial data in browser using ctrl+shift+x (or cmd+shift+x in Mac).

like image 81
Marek Lipka Avatar answered Jan 28 '26 04:01

Marek Lipka