Wouldn't it be great if... September 3rd, 2007
Mea culpa. Mea maxima culpa.
We want to override sections of a page layout on a per-action level. Stuff like the title tag or some javascript includes. Right now we've got a class called PageParameters. Want to include the javascript for ajax maps? Call...
page_parameters.set_map_scripts!
...in your controller. Or your before_filter. Or in some other PageParameters method. There's a dozen places people call those methods, so when there's a change you're playing Where's Waldo.
A better solution is overriding sections of layout right in the action's view. It's the principle of least surprise.
So I spent an hour creating a helper method called "for_layout." I was so happy that I bundled it in a plugin, and then found a bug. I checked the Rails API docs, and discovered content_for, which does everything I did, but better.
The best solution is avoiding the work in the first place.