I have this query in rails:
Extra.where("form_type = ?", 1)开发者_JS百科
However I would like to add a filter so the state also has to be Alabama. How can I do this? I tried this but it wouldn't work
Extra.where("form_type = ?", 1).and("state = ?", "Alabama")
Thanks in advance
Use a hash to specify AND conditions:
Extra.where(:form_type => 1, :state => "Alabama")
Give this a shot
Extra.where("form_type = ? AND state = ?", 1, "Alabama")
And of course, the meta_where solution:
Extra.where(:form_type >> 1 & :state >> % 'Alabama')
Extra.where(:form_type => 1, :state => "Alabama")
精彩评论