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 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
Ben W. 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 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
My apologies – I found a thread that had exactly what I wanted.
http://www.ruby-forum.com/topic/63761#69833
Thanks,
Ben
On 10/10/06, Ben W. [email protected] 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 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
<%= controller.action_name %>
or <%= controller.controller_name %>
etc.
If you want per-controller optional overrides, try:
<%= @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.
Ben W. <rails-mailing-list@…> writes:
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?
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
I’m using this:
Default Prefix - <%= $title || controller.action_name %>
if you want to change the title for some controller just overwrite
$title for this controller e.g. in the initialize method
Daniel