On Rails, is there a way to render content other than the <% =%> tag?

it seems like on Rails or erb the only way to output anything is on <% =%>

<% puts "hello"%> will not work, unlike PHP.

is there any other method?

+1


source share


2 answers


concat will do:

<% concat ("wah ha ha!") %>

      

Help:
http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M001710



from source code,

<% output_buffer << "hmm" %>

      

will work too, and it is checked ... but I think this is even lower level and should be avoided.

+2


source


The normal response object exists under the covers and you can call response.write (str). But a big part of the beauty of RoR is that this nut and bolt stuff is a distraction for you and you don't have to.



+1


source







All Articles