0

I've done! very lucky, I was working on it for about three days, what rewrote the code at my show view like this:

<ul>
<%= @tags.each do |z| %>
    <% if z.name == @tag.name %>
        <li style="visibility:hidden"><%= id = z.tagable_id %></li>
        <p>User name:<strong> <%= find_user(id)%></strong></p>
        <li>Post content:<strong><%= post = find_post(id)%></strong></li>
    <% end %>
<% end%>

</ul>

The problem now is that below the information an wried code is show, this code is the list of all the tags that I have:

[#<Tag id: 1, name: "septiembre", tagable_id: 301, tagable_type: "Post", created_at:       "2012-09-25 23:43:02", updated_at: "2012-09-25 23:43:02">, #<Tag id: 2, name: "Septiembre", tagable_id: 302, tagable_type: "Post", created_at: "2012-09-26 15:40:54", updated_at: "2012-09-26 15:40:54">, #<Tag id: 3, name: "Octubre", tagable_id: 302, tagable_type: "Post", created_at: "2012-09-26 17:11:04", updated_at: "2012-09-26 17:11:04">, #<Tag id: 4, name: "septiembre", tagable_id: 302, tagable_type: "Post", created_at: "2012-09-26 18:45:54", updated_at: "2012-09-26 18:45:54">, #<Tag id: 5, name: "septiembre\r\n", tagable_id: 303, tagable_type: "Post", created_at: "2012-09-27 00:09:36", updated_at: "2012-09-27 00:09:36">, #<Tag id: 6, name: "septiembre", tagable_id: 304, tagable_type: "Post", created_at: "2012-09-27 00:10:26", updated_at: "2012-09-27 00:10:26">, #<Tag id: 7, name: "Octubre", tagable_id: 305, tagable_type: "Post", created_at: "2012-09-27 00:10:47", updated_at: "2012-09-27 00:10:47">]

What do you think??

Julio Ahuactzin
  • 91
  • 2
  • 10
  • your result is fully logic: you extract elements one by one then try to match each one with some of the initial collection. Obviously, one element will always match itself, so you get them all – apneadiving Sep 26 '12 at 23:15

1 Answers1

0

Change <%= @tags.each do |z| %> to <% @tags.each do |z| %>. The = sign means render to the html so it shows the @tags variable.

ScottJShea
  • 7,041
  • 11
  • 44
  • 67