ruby on rails - "Where" method with "not nil" checking -


how can check if variable not nil when use "where" method ?

i tried these on product model has borrower_id field, didn't worked :

> product.where("borrower_id.nil?") > product.where("borrower_id != nil") > product.where("borrower_id == !nil") 

the way found 1 :

> product.where("borrower_id > 0") 

but doesn't seem clean...

try

product.where('borrower_id not null') 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -