Topic: record count sintaxe
Hi all, I´m newbie in Rails so I have 2 entities:
products and assets !
products has_many assets
assets belongs_to products
so in my view i´d like to show assets records count for each products, so the line is:
<% for product in @products %>
<h2><%= link_to product.title, product_path(product) %></h2>
<%= product.content %>
Total of Imagens = <%= @assets.count %>
<% end %>
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.count
how to do that ?
thanks in advance
Last edited by PowerTux (2013-03-19 19:34:12)