这几乎在Difference Between find and Where with Relationships中回答,但不完全相同。 (请注意,我是如何巧妙地改变了问题的标题!) 我做的查询“where”和“find”之间的区别
a = Libation.where("user_id = 1") # gets 10 records
b = a.sum("count * weight") # Get right answer
c = Libation.where("user_id = 2") # gets 8 records
d = c.sum("count * weight") # Get right answer
现在我做
e = Libation.all # gets 18 records, good
f = e.sum("count * weight") # BOOM! I get
NoMethodError (undefined method `+' for #<Libation:0x3b91e88>):
坚果。我试图找到相关的文档,但发现很少。或者我不在正确的位置。
谢谢,非常好的解释。关于时间我读了范围。 – rtfminc 2011-05-20 06:39:47