Reputation: 1054
How can I check if my variable is not nil when I use the "where" method ?
I tried these on a Product model that has a borrower_id field, but it didn't worked properly :
> Product.where("borrower_id.nil?")
> Product.where("borrower_id != nil")
> Product.where("borrower_id == !nil")
The only way I found was this one :
> Product.where("borrower_id > 0")
But it doesn't seem very clean...
Upvotes: 0
Views: 129
Reputation: 3339
Try these:
> Product.where("borrower_id !=?", nil)
> Product.where("borrower_id !=?", "")
Upvotes: 1