Partials and helpers


Is there any reason why helpers cannot render partials?

I would like to do something like this in the layout:

  <%= magic_header %>
  <%= yield %>

and then have a magic_header helper

def magic_helper some magic...
  render partial: "magic_helper"

Why is this wrong?

Luís Ferreira

What's it failing to do? I've used this pattern frequently for partials that need some extra argument preprocessing and haven't encountered problems.

--Matt Jones

Ups. You right. it does work, even though I had the idea it didn't.

Nonetheless, the real question was not using render, but render_to_string (or any ActionController helpers) that is not available from helpers.

Why is this so?