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.
9904f8acaf66a3c1a4b4434676be11cf?d=identicon&s=25 john (Guest)
on 2005-11-13 22: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 Kopanas

--
http://www.soen.info - where software engineering knowledge gets indexed
http://cusec.soen.info - software engineering conference
5565e460a42fbe5669b458b2753f8d34?d=identicon&s=25 codeslush (Guest)
on 2005-11-13 22:14
(Received via mailing list)
I use the following and it seems to work:


@params[:controller]



Regards,



Michael




John Kopanas <john@protoseinc.com> 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 Kopanas

--
http://www.soen.info - where software engineering knowledge gets indexed
http://cusec.soen.info - software engineering conference
5565e460a42fbe5669b458b2753f8d34?d=identicon&s=25 codeslush (Guest)
on 2005-11-13 22:17
(Received via mailing list)
And to see the other params available:

<%= debug(params) %>

within your view.

Regards,

Michael


John Kopanas <john@protoseinc.com> 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 Kopanas

--
http://www.soen.info - where software engineering knowledge gets indexed
http://cusec.soen.info - software engineering conference
2eb3541ea8ad17e478459d6bf3b2b874?d=identicon&s=25 ragg (Guest)
on 2005-11-13 22:20
(Received via mailing list)
I use controller.controller_name
5565e460a42fbe5669b458b2753f8d34?d=identicon&s=25 codeslush (Guest)
on 2005-11-13 22: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 Kopanas <john@protoseinc.com> 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 Kopanas

--
http://www.soen.info - where software engineering knowledge gets indexed
http://cusec.soen.info - software engineering conference
B84d42a3a5c343f8fc6ab7d7f47fd3f5?d=identicon&s=25 robby.lists (Guest)
on 2005-11-13 22: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
5565e460a42fbe5669b458b2753f8d34?d=identicon&s=25 codeslush (Guest)
on 2005-11-14 00: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 Russell <robby.lists@planetargon.com> 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.