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

StackOverflow https://stackoverflow.com/questions/22856961

Pergunta

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.

Foi útil?

Solução

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).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top