Gael Pourriel
2006-May-15 13:30 UTC
[Rails] Retrieve the current controller name from a view
Hi all, I wonder if it''s possible to retrieve the current controller name and possibly the action when you''re in a view. i.e. I call the same template/partial view from different controllers and I''d like to know when I''m in the view code which controller is calling it... Any ideas? Sorry if it''s obvious but I couldn''t find it in the doc. Gael
Jon Gretar Borgthorsson
2006-May-15 13:39 UTC
[Rails] Retrieve the current controller name from a view
<%= controller.controller_name -%> <%= controller.action_name -%> On 5/15/06, Gael Pourriel <gael.pourriel@gmail.com> wrote:> Hi all, I wonder if it''s possible to retrieve the current controller > name and possibly the action when you''re in a view. > > i.e. I call the same template/partial view from different controllers > and I''d like to know when I''m in the view code which controller is > calling it... > > Any ideas? Sorry if it''s obvious but I couldn''t find it in the doc. > > Gael > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- -------------- Jon Gretar Borgthorsson http://www.jongretar.net/
Gael Pourriel
2006-May-15 13:46 UTC
[Rails] Retrieve the current controller name from a view
Thanks, I knew it would be that simple.... On 15/05/06, Jon Gretar Borgthorsson <jon.borgthorsson@gmail.com> wrote:> <%= controller.controller_name -%> > <%= controller.action_name -%> > > On 5/15/06, Gael Pourriel <gael.pourriel@gmail.com> wrote: > > Hi all, I wonder if it''s possible to retrieve the current controller > > name and possibly the action when you''re in a view. > > > > i.e. I call the same template/partial view from different controllers > > and I''d like to know when I''m in the view code which controller is > > calling it... > > > > Any ideas? Sorry if it''s obvious but I couldn''t find it in the doc. > > > > Gael > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > -------------- > Jon Gretar Borgthorsson > http://www.jongretar.net/ > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >