I agree, this does clutter up your controller... but since page titles
are usually action-specific I can't think of a better place for them.
You wouldn't want to try and rig something like this in the model... and
passing it off into the view (i.e. scrubbing it out of an <h1>) doesn't
feel right other. Maybe a before_filter? it would get it out of your
individual action methods and down at the bottom of the controller.
Something like...
before_filter :load_page_title
private
def load_page_title
@page_title=
case controller.action_name
when "news"
"News"
when "show"
@object.name
end
end
Just throwing stuff out there....
-Nathan
Patrick Crowley wrote:
When I need to set the title for a page (not inline... the one that
appears in your browser's window bar), I usually do something like
this...
def news
@title = 'News'
end
And in my main layout...
<head>
<title>My web app<% if @title != nil %> -- <%= @title %><% end
%></title>
</head>
So, this way, you can set an optional title for actions that need one.
Works pretty well, but I'd prefer not to clutter up my controller code
with all those titles.
Can you guys think of a way to grab the page title from an inline <h1>
and then map that to @title?
-- Patrick
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby