Forum: Ruby on Rails Getting Controller and Action Names

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.
john (Guest)
on 2005-11-13 23:11
(Received via mailing list)
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
codeslush (Guest)
on 2005-11-13 23:14
(Received via mailing list)
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
codeslush (Guest)
on 2005-11-13 23:17
(Received via mailing list)
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
ragg (Guest)
on 2005-11-13 23:20
(Received via mailing list)
I use controller.controller_name
codeslush (Guest)
on 2005-11-13 23:23
(Received via mailing list)
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
robby.lists (Guest)
on 2005-11-13 23:50
(Received via mailing list)
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
codeslush (Guest)
on 2005-11-14 01:41
(Received via mailing list)
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
This topic is locked and can not be replied to.