Getting Controller and Action Names


#1

I figured it would be the easiest thing to do but for some odd reason
I am having a hard time to figure out how to do this.

I can get the action using @action_name but I can’t get the
controller using @controller_name. What is the correct way to go
about doing this?

Thanks for your help.

Your Friend,

John K.


http://www.soen.info - where software engineering knowledge gets indexed
http://cusec.soen.info - software engineering conference


#2

I use the following and it seems to work:

@params[:controller]

Regards,

Michael

John K. removed_email_address@domain.invalid wrote:
I figured it would be the easiest thing to do but for some odd reason
I am having a hard time to figure out how to do this.

I can get the action using @action_name but I can’t get the
controller using @controller_name. What is the correct way to go
about doing this?

Thanks for your help.

Your Friend,

John K.


http://www.soen.info - where software engineering knowledge gets indexed
http://cusec.soen.info - software engineering conference


#3

I use controller.controller_name


#4

And to see the other params available:

<%= debug(params) %>

within your view.

Regards,

Michael

John K. removed_email_address@domain.invalid wrote:
I figured it would be the easiest thing to do but for some odd reason
I am having a hard time to figure out how to do this.

I can get the action using @action_name but I can’t get the
controller using @controller_name. What is the correct way to go
about doing this?

Thanks for your help.

Your Friend,

John K.


http://www.soen.info - where software engineering knowledge gets indexed
http://cusec.soen.info - software engineering conference


#5

Not sure why my last reply didn’t get to this list. I’ll try again - if
it shows up then sorry for the duplicate post:

@params[:controller]

Regards,

Michael

John K. removed_email_address@domain.invalid wrote:
I figured it would be the easiest thing to do but for some odd reason
I am having a hard time to figure out how to do this.

I can get the action using @action_name but I can’t get the
controller using @controller_name. What is the correct way to go
about doing this?

Thanks for your help.

Your Friend,

John K.


http://www.soen.info - where software engineering knowledge gets indexed
http://cusec.soen.info - software engineering conference


#6

On Sun, 2005-11-13 at 13:12 -0800, Michael wrote:

I use the following and it seems to work:

@params[:controller]

Michael,

Just a quick, FYI…

@params, @request, etc… are deprecated.[1]

You can and should now use params, request, etc.

[1] http://rubyurl.com/xaG (params v.s. @params in rails?)

Cheers,

Robby


#7

Thank you Robby! Interestingly, I am new to Rails - I think I got the
info from the agile book. I will switch accordingly…

Michael

Robby R. removed_email_address@domain.invalid wrote:
On Sun, 2005-11-13 at 13:12 -0800, Michael wrote:

I use the following and it seems to work:

@params[:controller]

Michael,

Just a quick, FYI…

@params, @request, etc… are deprecated.[1]

You can and should now use params, request, etc.

[1] http://rubyurl.com/xaG (params v.s. @params in rails?)

Cheers,

Robby