Forum: Ruby on Rails How to test for controller

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
bohara (Guest)
on 2005-12-02 20:55
(Received via mailing list)
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?

Thanks,
Beau
technoweenie (Guest)
on 2005-12-02 20:55
(Received via mailing list)
On 12/2/05, Beau O'Hara <removed_email_address@domain.invalid> wrote:
> <% end %>
>
> What is the variable name to get at the current controller?

<% if controller.controller_name == 'admin' -%>

--
rick
http://techno-weenie.net
This topic is locked and can not be replied to.