Oleg Pasko
Oleg Pasko

Reputation: 2911

Rails 3.1: 'where' with multiple conditions and 'not nil' verification

I want to find records with multiple conditions and this is my code:

@calhappybd = Client.where(:user_id => current_user.id, "birth IS NOT NULL")

I'm trying to do this with squeel-gem, but when I try to use multiple conditions (where{(cond1)(cond2)}), but my current_user.id defined as simple string-data.

Upvotes: 0

Views: 2219

Answers (1)

dexter
dexter

Reputation: 13583

With squeel, you should be able to do something like

@calhappybd = Client.where{(user_id == current_user.id) & (birth != nil)}

Let know if you get the same error again...

UPDATED:

Modified the conditions above. Note the single ampersand and double equals. That works for me..

My configuration:

rails 3.1.0.rc6
squeel 0.8.8

Upvotes: 3

Related Questions