I think it does belong in the view, actually.
Your solution isn't bad (though I'd make it a helper instead), but
I'm thinking about something more automagic.
While I haven't figured out a technical solution for this yet, I like
the implict DRYness of setting the title once, in the view, and not
worrying about it again.
I guess title-izing the current action name could work, but that'd
get a bit gnarly with super long page titles.
-- Patrick
On Feb 23, 2007, at 12:29 pm, Nathan Colgate Clark wrote:
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
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby