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
End
def baz
@side_nav = :hide_admin
EndEnd
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
-----Original Message-----
From: Rick Olson [mailto:technoweenie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
Sent: Friday, December 02, 2005 10:55 AM
To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails] How to test for controller
On 12/2/05, Beau O''Hara
<bohara-Ani+Op4kYNUXWzRTk0ed69BPR1lH4CV8@public.gmane.org>
wrote:> I have a side navigation that i want to change based on the
controller.> How would i test for this in .rhtml. for example lets say i have an
> admin controller.
>
> Example
> --------------------
> <% if @controller = admin %> ---- What actually would this syntax be?
> <% @categories.each do |category| %>
> <%= link_to category.name, :action =>
"list_by_cat", :id =>
> category.id %><br />
> <% end %>
>
> What is the variable name to get at the current controller?
<% if controller.controller_name == ''admin'' -%>
--
rick
http://techno-weenie.net
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails