RE: How to test for controller

There is a reason the controller is called controller. The controller
should be making this type of decision.

I would do it this way:

Class FooController < ApplicationController
def bar
@side_nav = :display_admin
def baz
@side_nav = :hide_admin

In the view:
<% if @side_nav == :display_admin %>

<% end %>

In your application controller, you can set a default value for the
@side_nav variable to avoid needing to set it in every action

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs