9

I am converting my fat Rails2 application to run on Rails3. After a long intense fight with an army of bugs and my bosses yells, the page is all rendered as an escaped html string. So all the divs, images etc. are written literally for the user.

For some reason this call of a partial renders an escaped string

<%= render :partial => 'something_really_interesting' %>

As all Ruby on Rails application this instruction is not called very much! So how would I handle all these calls to not render normally not as an escaped string?

user229044
  • 232,980
  • 40
  • 330
  • 338
wael34218
  • 4,860
  • 8
  • 44
  • 62

1 Answers1

18

Use <%= raw bla %> in inside the partial file.

Rails 3 automatically makes everything safe. You need to put raw to escape the behavior. That also means you don't have to use h() method to make your string safe any more.

TK.
  • 27,073
  • 20
  • 64
  • 72
  • This helped me, thank you. In my case, I render the partial directly from another template, as well from a helper which is called by a different template. Also, my partial is a form, so I didn't want to call raw for every string output. It works! – Docunext Mar 26 '11 at 19:21