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 testin开发者_StackOverflowg 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
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
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.
<% @findlist.each do |list| %>
<% list.products.each do |product| %>
<p>
<b>Product:</b>
<%=h image_tag(product.photo.url) %>
</p>
<% end %>
<% end %>
精彩评论