Reputation: 220
I manually add file paths to my partials so that it's easy for me to debug them. The code uses slim syntax:
= print_partial_dir 'admin/modules/_menu-left.html.slim'
def print_partial_dir(path)
"<!-- #{path} -->".html_safe if Rails.env.development?
end
Is there anyway so that when I render a partial in a view, I execute a filter or a hook so that the partial's file path is printed as a comment before the partial itself? Preferably, only do this when the rails environment is in development.
Upvotes: 0
Views: 332
Reputation: 727
If you really want debugging be eased by getting partial rendering information you can use gem "xray-rails"
group :development do
gem 'xray-rails'
end
Then bundle and delete your cached assets:
$ bundle && rm -rf tmp/cache/assets
Restart your app, visit it in your browser, and press cmd+shift+x (Mac) or ctrl+shift+x to reveal the overlay ( Documentation)
In this way you can debug all your partials when they are rendered.
Hope this Helps..
Upvotes: 1