How to determine the current controller?

S

Sven Gehring

Hi guys,

I want to build a generic navigation menu with partials in the style of

if current_controller == 'abcd'
render pratial 'abscd'

How can I determine the current controller from within the layout .rhtml
file without taking care of what action is executed?

If I use current_page?:)controller => 'abcd') it works as long as the
current_page is http://localhost:3000/abcd
 
N

nas

you have an instance variable available in your views called
@controller

hence you can use something like

if @controller.controller_name == 'abcd'
do something
else
do somthing else
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,109
Latest member
JanieMalco
Top