Alright, I was very happy iterating over items table when suddenly BANG!
NoMethodError in Items#index
undefined method `stringify_keys' for "/items/7":String
Why like this?
Item Controller
def index
@item = current_user.bar.items.all
end
Item Index View
<% current_user.bar.items.each do |item|%>
<tr>
<td><%= link_to(image_tag( item.foto.url.to_s), item.name, item_path(item.id)) %></td>
</tr >
<% end %>
Check out the method signature for link_to.
You’re handing it an image, some text, and a path. That’s wrong. The reason you’re getting that error is because
link_tothinks that the last argument is an options hash, when really, it’s a string (the path). You need to remove theimage_tag, theitem.name, or simply provide a block to include them both: