1

I have a lot of views that have the exact same code in the beginning and the end of each document.

Is there any way in Rails to avoid this duplication?

Fellow Stranger
  • 32,129
  • 35
  • 168
  • 232

1 Answers1

4

The information is kind of hard to find, but this is covered in the "Rendering partials with layouts" section of the partials documentation. Basically when you do render partial: ... you can use the layout: option to give the name of the "wrapper" layout. The partial will be rendered within the wrapper wherever you put <%= yield %>.

Jordan Running
  • 102,619
  • 17
  • 182
  • 182