Rails中的WHERE语句?

时间:2012-02-15 12:15:59

标签: ruby-on-rails ruby-on-rails-3

只是想知道这样构造语句的正确方法是什么?

 @products = Product.where('release_date <= ?', Date.today AND 'physical_status' == 'active')

谢谢!

1 个答案:

答案 0 :(得分:2)

您正在寻找的是:

@products = Product.where('release_date <= ? AND physical_status = ?', Date.today, 'active')

您可以查看本指南:http://guides.rubyonrails.org/active_record_querying.html