Reputation: 906
I have a model with a string attribute. This attribute (status) is updated to seen
, notseen
, hired
, and reject
depending on certain variables within my app.
I would like to count all records where status != reject
.
Looking at the docs here it looks like it should be something like;
<%= Mymodel.count(:conditions => [ "status = ?", 'reject' ]) %>
but this is not correct, it returns a count of all instances regardless of status.
How can I achieve this?
Upvotes: 0
Views: 585
Reputation: 2610
Try the below
<%= MyModel.where.not(:status => 'reject').count %>
Upvotes: 1
Reputation: 184
Maybe something like this:
<%= MyModel.where.not(status: 'reject').count %>
Upvotes: 1