I am seeking a way to do the opposite of :
Model.where(:name => 'julian')
Something like :
Model.where(:name => is_not('julian'))
I have found this post. But, find(:all, :conditions => {}) is now deprecated in rails 3 and moreover, I think a cleaner way to do this must exist.
Any suggestion ?
The simple answer is:
Model.where('models.name != ?', 'julian')
Unless, you want to get into building actual Arel conditions, in which case you would do something like:
Model.where(Model.arel_table[:name].not_eq('julian'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With