Forum: Ruby on Rails Detect current controller and action

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.
C7d5bc5b054035d95f287797c2595694?d=identicon&s=25 matiassurdi (Guest)
on 2005-12-04 13:30
(Received via mailing list)
How can I detect the controller and action from a request?

Thanks..
81194a50c0f9bd95d7832a77fdf371bd?d=identicon&s=25 cool_screen_name90001 (Guest)
on 2005-12-04 20:23
(Received via mailing list)
@params[:controller] and @params[:action]

csn


--- Matias Surdi <matiassurdi@gmail.com> wrote:

> How can I detect the controller and action from a request?
>
> Thanks..
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>




__________________________________________
Yahoo! DSL ? Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com
0bcc972918891ef358b0b3dfb4e7f18b?d=identicon&s=25 hammed (Guest)
on 2005-12-04 21:12
(Received via mailing list)
In views:

controller.name
controller.action_name

will give you the controller and action names.
Cee0292fffa691f1fb320d5400200e99?d=identicon&s=25 marcel (Guest)
on 2005-12-04 21:45
(Received via mailing list)
On Sun, Dec 04, 2005 at 03:10:07PM -0500, Hammed Malik wrote:
>    In views:
>
>    controller.name
>    controller.action_name

You can't just do controller.class.name because the controller class is
called
FooController. Like 'action_name', there is a specialized
'controller_name'
method.

>> PublicationController.new().class.name
=> "PublicationController"

>> PublicationController.new().controller_name
=> "publication"

marcel
0bcc972918891ef358b0b3dfb4e7f18b?d=identicon&s=25 hammed (Guest)
on 2005-12-04 22:01
(Received via mailing list)
I stand corrected. Thanks.
C7d5bc5b054035d95f287797c2595694?d=identicon&s=25 matiassurdi (Guest)
on 2005-12-05 10:48
(Received via mailing list)
Hammed Malik
escribió:>      >    controller.action_name
>      >> PublicationController.new().controller_name
>     http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails


thanks everybody, I solved my problem with these things you said me...

thanks..

Matias
This topic is locked and can not be replied to.