0

我弄完了!非常幸运,我花了大约三天的时间在我的显示视图中重写了代码,如下所示:

<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>

现在的问题是,在信息下方显示了一个编写的代码,该代码是我拥有的所有标签的列表:

[#<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">]

你觉得怎么样??

4

1 回答 1

0

更改<%= @tags.each do |z| %><% @tags.each do |z| %>。= 符号表示渲染到 html,因此它显示@tags变量。

于 2012-09-27T02:15:30.313 回答