conditions的hash写法

一般,我们会这样来写conditions:

 

    Space.all(:conditions => ["active = ? and status = ?", false, 0])
    User.all(:include => [:photos], :conditions => ["photos.removed = ? and users.active = ?", false, true])

 

现在,我们也可以以hash的形式来写conditions:

 

    Space.all(:conditions => {:active => false, :status => 0})
    User.all(:include => [:photos], :conditions => {"photos.removed" => false, "users.active" => true})

 

你可能感兴趣的:(Condition)