I need to count all the microposts of my image where the status is equal to new .
<% for column in @images %>
<%= column.id %>
<%= column.microposts.count() %>
<% end %>
I have tried this line but it doesn't work:
<%= column.microposts.count(" WHERE status='new' ") %>
Is there a way I can add a condition ?
column.microposts.where(:status => 'new').count
column.microposts.find_all_by_status('new').count
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.