ERB has an internal buffer that makes using blocks a bit more complicated, as you can see in your code example.
Rails provides a capture method that allows you to write a string inside this buffer and return it from a block.
So, your assistant will be as follows:
def make_backwards capture do yield.reverse end end
source share