Forum: Ruby on Rails RE: How to test for controller

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Tom (Guest)
on 2005-12-02 21:07
(Received via mailing list)
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 topic is locked and can not be replied to.