array in view

10 views
Skip to first unread message

fugee ohu

unread,
Nov 24, 2015, 8:07:23 PM11/24/15
to Ruby on Rails: Talk
I want my view to print the category names but my browser's displaying an array  first, then the category name Why is it displaying this array I am using acts_as_nested_set in my controller but I don't think that should be the issue

<div>
<table>
  <%= @categories.each do |category| %>
   <tr><td><%= category.name %></td>
  <% end %>
</table>
</div>

Carlos Eduardo Ribeiro

unread,
Nov 24, 2015, 8:20:49 PM11/24/15
to rubyonra...@googlegroups.com
Only use <%= for text output

Change <%= on array iterate to <% only


 <%= @categories.each do |category| %>
<% @categories.each do |category| %>

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/03b275f6-a524-4feb-aafc-bb3460c3cd9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages