Reputation: 1125
I call the same partial from multiple views in Rails, the show page and the edit page. How can I keep track of which view the partial is called from? More specifically, I would like to adapt the partial slightly depending on which page it is rendered from. I have tried to request the uri using url_for(:only_path => true)
and if-else statements to determine if the partial is rendered on the show or edit page, but this is a bit cumbersome. Is there a better approach?
Upvotes: 1
Views: 328
Reputation: 2804
We put this in our application.html.erb template which shows the current controller, view and more debug information:
<%= debug(params) if Rails.env.development? %>
I think we got this from the Rails site:
http://guides.rubyonrails.org/debugging_rails_applications.html
Upvotes: 1
Reputation: 675
you can try to use current_page?
helper, i.e. if current_page?(root_path)
Upvotes: 1