1

快一个,但我想我会问。

有没有比这样更好的方法从模型的列中获取列值?

Item.count(:all, :group => 'status').reject! { |i, e| i.blank? }.collect { |i,e| i}
4

2 回答 2

2
Item.find(:all, :select=>:status, :group => 'status', :conditions => "status != ''").collect{|r| r.status}
于 2009-01-10T15:51:46.407 回答
-1

和下面的代码是一样的吗?

Item.count(:all, :group => "status", :conditions => "status != ''"}

.. 也许不吧 ..

但是您能否指定更多您想要的标准?即状态为空白?计数为空?

于 2009-01-10T15:24:56.663 回答