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?
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?
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 %>
.