首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >助手函数Rails 3失败

助手函数Rails 3失败
EN

Stack Overflow用户
提问于 2012-09-27 06:55:02
回答 1查看 95关注 0票数 0

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

代码语言:javascript
复制
<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>

现在的问题是,在显示了all代码的信息下面,这个代码是我拥有的所有标签的列表:

代码语言:javascript
复制
[#<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">]

你认为如何??

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-27 10:15:30

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12611674

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档