Reputation: 2261
I was trying to count my objects and to show the number in view by doing something like this:
show.html.erb:
<%Files.where(defined:"yes").count do |number|%>
<%= number %>
<% end %>
But it shows nothing. Where is the problem? Thanks a lot.
Upvotes: 0
Views: 36
Reputation: 124479
.count
returns an integer value, not an array, so you can't iterate over it. Just do this:
<%= Files.where(defined: "yes").count %>
Upvotes: 4