How to get current method/action name from layout rhtml

I want to know what is current controller / action in my layout.rhtml
shared by all my rhtml files to make some style changes.

I am new in ruby and RoR, I believe there must be a simple solution for
this.

Any help would be great appreciated!!!

Roseanne

There sure is a better soluition, but i added a before_filter in my
application controller like this:

before_filter :set_canames


private
def set_canames
@cname = controller_name
@aname = action_name
end

there probably is a better way, but it works.

In your views, you can use controller.controller_name and I’m sure there
is
a method for the action but I don’t know it off the top of my head.
action_name would make the most sense.

On 10/13/06, Thorsten L [email protected] wrote:

@cname = controller_name
@aname = action_name
end

there probably is a better way, but it works.


-B

Long wrote:

Thorsten L wrote:

controller.controller_name
controller.action_name

Long

Thanks everybody!!!
Thanks Long!!!

It works great!

Roseanne

Thorsten L wrote:

@aname = action_name
end

there probably is a better way, but it works.

There was a recent post with similar information. I believe you do have
access to ‘controller’ in the views (and layouts) therefore it is
possible to use

controller.controller_name
controller.action_name

Long

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