Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
快一个,但我想我会问。
有没有比这样更好的方法从模型的列中获取列值?
Item.count(:all, :group => 'status').reject! { |i, e| i.blank? }.collect { |i,e| i}
Item.find(:all, :select=>:status, :group => 'status', :conditions => "status != ''").collect{|r| r.status}
和下面的代码是一样的吗?
Item.count(:all, :group => "status", :conditions => "status != ''"}
.. 也许不吧 ..
但是您能否指定更多您想要的标准?即状态为空白?计数为空?