ruby on rails - How to show app data in erb template? -
I first thought that a Ruby code is accepted, but I have found this strange behavior ...
I have an array of tags for my article, and I want to do a good job for them. So I'm writing something like this:
& lt; Ul & gt; & Lt;% @ post.tags.each do Items | & Gt%; & Lt; Li & gt; Item & lt; / Li & gt; & Lt;% end% & gt; & Lt; / Ul & gt;
Incorrect output looks like this:
& lt; Ul & gt; & Lt; Li & gt; Item & lt; / Li & gt; & Lt; Li & gt; Item & lt; / Li & gt; & Lt; Li & gt; Item & lt; / Li & gt; ... & lt; / Ul & gt;
Where am I wrong? Any suggestions on how to make proper trends?
You forgot & lt;% =%>
to display the value of item
& lt; Ul & gt; & Lt;% @ post.tags.each do Items | & Gt%; & Lt; Li & gt; & Lt;% = item% & gt; & Lt; / Li & gt; & Lt;% end% & gt; & Lt; / Ul & gt;
Comments
Post a Comment