view - Iterative display of objects in Rails -
i find when iteratively render collection of objects, say, comments, rails lists addresses of objects. example, view may contain following:
<h3>comments</h3> <% if @blogpost.comments.any? %> <%= @blogpost.comments.each |comment| %> <%= render :partial => "comment", :locals => {:comment => comment} %> <% end %> <% end %>
the view shows this:
<h3>comments</h3> <p>comment #2</p> <p class="post-info"> >> example user, 1 hour ago. </p> <p>this user 1's comment on user 5's article</p> <p class="post-info"> >> example user, 2 days ago. </p> #<comment:0xb6f91968>#<comment:0xb6f9016c>
as can see, there couple of address listings objects, prefer not have in view. there way suppress output? in advance time!
remove = <%= @blogpost.comments.each |comment| %>
when add = in <% %> rails execute erb code , render output in html.
Comments
Post a Comment