I''m sure it''s a simple answer, but I''m trying to access which controller a view is being displayed from within a layout. Basically what I want to do is pull out the controller name from the URL. For example: /localhost/my_controller/new I want to be able to get out ''my_controller'' when my standard-layout is generated, and from there render different menu items based on the options that pertain to that particular controller. Help would be appreciated, thanks in advance -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
controller.controller_name On Aug 15, 10:06 am, Chris Metcalfe <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''m sure it''s a simple answer, but I''m trying to access which controller > a view is being displayed from within a layout. Basically what I want > to do is pull out the controller name from the URL. > > For example: > /localhost/my_controller/new > > I want to be able to get out ''my_controller'' when my standard-layout is > generated, and from there render different menu items based on the > options that pertain to that particular controller. > > Help would be appreciated, thanks in advance > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
beauty, thanks. figured it was real simple! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> I''m sure it''s a simple answer, but I''m trying to access which controller > a view is being displayed from within a layout. Basically what I want > to do is pull out the controller name from the URL. > > For example: > /localhost/my_controller/new > > I want to be able to get out ''my_controller'' when my standard-layout is > generated, and from there render different menu items based on the > options that pertain to that particular controller.params[:controller] should have it... We put the below in our layout so we can view the source and see the host, controller, and action for any given page... sometimes it''s useful in debugging. <!-- <%= Socket.gethostname.sub(/\..*/, '''') %> : <%= (params[:controller] + ''/'' + params[:action]) rescue '''' %>--> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---