I haven't used it, but this looks like what you want to do:
That said, I think it should also be possible to rethink your layout
and use partials to avoid RY.
Keep up to date with Rails on Twitter and This Week in Rails
Policies: Conduct, License, Maintenance, Security, Trademarks