ruby on rails - How to display content that differs across controllers and methods in application layout? -


I'm trying to display JavaScript feedback widget in your default application.rhtml a rail application. It will only appear on subsets of pages distributed in different controllers.

The best way to do this is to try to find out.

One thought was to do something like this:

  & lt;% = render: partial = & gt; "Layout / feedback_tab" if @shave_feedback_tab == true%>  

And then in each control set up @ show_feedback_tab in each method. It's complicated My second thought was that I could make default to correct @show_feedback_tab and it can be set to false for the respective individual methods where I do not want it. But a global variable does not look right, and no method will work in application_controller (I think) because the display is dependent on the method that is being called.

Any thoughts?

You can write method application_controller.rb are:

  def Show_feedback_tab? If the consultation [: Controller] ==: User & amp; Amp; Params [: action] ==: Index returns true end ... or any other reason ... is wrong and  
Here

and add it as a helper method (in application_controller.rb ):

  support_package: show_feedback_tab?  

Then you can view it as:

  <% = render: partial = & gt; "Layout / feedback_tab" if show_feedback_tab? & Gt%;  

Comments