意外的 kEND
1 <p>
2 <b>Name:</b>
3 <%=h @findlist.name %>
4 </p>
5
6 <p>
7 <b>Cached slug:</b>
8 <%=h @findlist.cached_slug %>
9 </p>
10
11 <h4>Products</h4>
12 <% @findlist.products.each do |product| %>
13 <p>
14 <b>Product:</b>
15 <%=h image_tag(product.photo.url) %>
16 </p>
17 <% end %>
18
19 <%= link_to 'Edit', edit_user_findlist_path(@user, @findlist) %> |
20 <%= link_to 'Back', findlists_path %>
我目前有上面的代码,但它在第 12 行左右给出了“意外的 kEND,期望 $end”。我一直在测试和测试代码,我看不到语法错误。我是 ruby 和 Rails 的新手,我可能只是看不到它。
任何帮助将不胜感激。
更新:删除第 12 至 17 行可删除语法错误
控制器代码:
7 def show
8 @findlist = @user.findlists.all
9 end
我正在使用 Rails 2.3.11
1 <p>
2 <b>Name:</b>
3 <%=h @findlist.name %>
4 </p>
5
6 <p>
7 <b>Cached slug:</b>
8 <%=h @findlist.cached_slug %>
9 </p>
10
11 <h4>Products</h4>
12 <% @findlist.products.each do |product| %>
13 <p>
14 <b>Product:</b>
15 <%=h image_tag(product.photo.url) %>
16 </p>
17 <% end %>
18
19 <%= link_to 'Edit', edit_user_findlist_path(@user, @findlist) %> |
20 <%= link_to 'Back', findlists_path %>
I currently have the above code but it gives me the "unexpected kEND, expecting $end" at around line #12. I have been testing and testing the code and I can't see the syntax error. I am a ruby and rails newbie and I probably just couldn't see it.
Any help would be appreciated.
UPDATE: removing lines 12 to 17 removes the syntax error
Controller code:
7 def show
8 @findlist = @user.findlists.all
9 end
I am using rails 2.3.11
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你得到@findlists并遍历@findlist:)这真的是错误吗?或者在这里粘贴代码时出错?因为我看到你在每个之前都使用了@findlist。
该错误来自另一个文件。-来自评论
You get @findlists and traverse @findlist :) Is this really the error though ? Or a mistake on pasting code here ? Because i see that you use @findlist before each.
The error is from another file.- from comment
我猜测 findlist 和 products 实际上是什么,但是如果 @findlist 是一个事物列表,并且每个事物都有产品,那么您需要突破到一个子循环。
I'm guessing at what findlist and products actually are, but if @findlist is a list of things, and each thing has products, then you need to break out into a sub-loop.