How do I add a controller-specific menu (or div) inside a general application layout in Rails?
method 1: set a variable in that controller
class SomeController
before_filter :set_to_use_menu
private
def set_to_use_menu
@use_menu = true
end
end
method 2: determine the controller's name in the layout
<%- if controller_name == "your_controller_name" %>
<%= render :partial => "the_menu" %>
<%- end %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With