Detecting controller in application layout

Hi:

In the application layout file (application.rhtml in /views/layout/),
I’m executing some logic to not load some files unless the user is
logged in. THat’s working well, but I need to take that logic to the
next step by doing the following:

I want to detect the controller that’s being called in the application
layout file (I’m not using separate layouts, everything starts with
application.rhtml), and execute logic based on the controller that’s
detected. I was unable to find anything on the boards that helped; is
there a way to detect the controller in a view?

Thanks very much in advance for your help!

Mike

Got it! Finally got the search string right:

    <%= params[:controller] %>
    <%= params[:action] %>

Thanks!

Also works:

    <%= controller.controller_name %>
    <%= controller.action_name %>

–Andrew V.

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