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.
matiassurdi (Guest)
on 2005-12-04 14:30
(Received via mailing list)
How can I detect the controller and action from a request?

Thanks..
cool_screen_name90001 (Guest)
on 2005-12-04 21:23
(Received via mailing list)
@params[:controller] and @params[:action]

csn


--- Matias S. <removed_email_address@domain.invalid> wrote:

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




__________________________________________
Yahoo! DSL ? Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com
hammed (Guest)
on 2005-12-04 22:12
(Received via mailing list)
In views:

controller.name
controller.action_name

will give you the controller and action names.
marcel (Guest)
on 2005-12-04 22:45
(Received via mailing list)
On Sun, Dec 04, 2005 at 03:10:07PM -0500, Hammed M. 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
hammed (Guest)
on 2005-12-04 23:01
(Received via mailing list)
I stand corrected. Thanks.
matiassurdi (Guest)
on 2005-12-05 11:48
(Received via mailing list)
Hammed M.
escribió:>      >    controller.action_name
>      >> PublicationController.new().controller_name
>     http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> 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.