开发者

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

开发者 https://www.devze.com 2023-03-31 13:08 出处:网络
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 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 tr开发者_Go百科ying 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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消