Hey everyone, Right now I wrap all my pages in an application-level layout. It writes the header, the encompassing body, etc. I''d like to have a default value for the <title/> that could be overridden by a controller method. All I can think of is defining a @title variable for every controller method -- and it seems redundant. What''s the best way to go about this? Thanks, Ben -- 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 -~----------~----~----~----~------~----~------~--~---
Ben Winekur wrote:> Hey everyone, > > Right now I wrap all my pages in an application-level layout. It writes > the header, the encompassing body, etc. I''d like to have a default value > for the <title/> that could be overridden by a controller method. All I > can think of is defining a @title variable for every controller method > -- and it seems redundant. What''s the best way to go about this? > > Thanks, > BenMy apologies -- I found a thread that had exactly what I wanted. http://www.ruby-forum.com/topic/63761#69833 Thanks, Ben -- 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 -~----------~----~----~----~------~----~------~--~---
Michael Campbell
2006-Oct-10 14:50 UTC
Re: Different <title> per action, when using layouts?
On 10/10/06, Ben Winekur <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hey everyone, > > Right now I wrap all my pages in an application-level layout. It writes > the header, the encompassing body, etc. I''d like to have a default value > for the <title/> that could be overridden by a controller method. All I > can think of is defining a @title variable for every controller method > -- and it seems redundant. What''s the best way to go about this?I think you can simply use <title><%= controller.action_name %></title> or <title><%= controller.controller_name %></title> etc. If you want per-controller optional overrides, try: <title><%= @title || controller.controller_name %> Then just define @title for the controllers that you want to have the layout use something other than the controller name. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ben Winekur <rails-mailing-list@...> writes:> All I can think of is defining a <at> title > variable for every controller method > -- and it seems redundant. What''s the best way to go about this?Well, at the end of the day you''re going to need *something* which is different for every title you want to have, so I would think that per-method would be ideal --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Daniel Guettler
2006-Oct-10 19:32 UTC
Re: Different <title> per action, when using layouts?
I''m using this: <title>Default Prefix - <%= $title || controller.action_name %></title> if you want to change the title for some controller just overwrite $title for this controller e.g. in the initialize method Daniel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---