在我们的 rails 3.2 应用程序中,我们需要从客户表中检索所有客户记录并将它们分配给一个变量,然后对变量customers进行查询(例如 .where(:active => true) customers。这里有两个问题:
检索所有记录的更好方法是什么?
Customer.all作品。但是根据 rails 文档,当客户表变大时可能会出现性能问题。我们试过Customer.find_each了,它有错误"no block given (yield)"。如何使变量
customersquery_able?对变量
customers(如customers.where(:active => true))执行查询时,出现错误:undefined methodwhere' for #customers where. It seems that thecustomers`以这种方式可以查询?is an array object and can't take. How can we retrieve
感谢帮助。