Rails 3;在where子句中添加'和'

时间:2014-06-17 12:52:42

标签: mysql sql ruby-on-rails

我有以下查询返回方向为nil的所有注册...

@registrations = Registration.includes(:orientation).
                  where(orientations: {:class_date => nil})

我需要添加第二个过滤器,所以我只是一个特定的姓氏,所以像......

@registrations = Registration.includes(:orientation).
                  where(orientations: {:class_date => nil AND :last_name => "smith"})

但是,此语法不正确。如何添加'AND'或&&声明到这个where子句的结尾?

1 个答案:

答案 0 :(得分:3)

所有键/值对都加入where() AND

Registration.includes(:orientation).
  where(orientations: {:class_date => nil}, :last_name => "smith")