如何干燥named_scope扩展名
|
给出以下代码:
named_scope :by_order, :order => \'priority ASC\' do
def total_points
self.sum(\'point_value\')
end
end
named_scope :required, :conditions => [\'bonus = ?\', false] do
def total_points
self.sum(\'point_value\')
end
end
named_scope :bonus, :conditions => [\'bonus = ?\', true] do
def total_points
self.sum(\'point_value\')
end
end
您将如何干燥重复的total_points方法?
环境:Rails 2.3.11
没有找到相关结果
已邀请:
1 个回复
痴浪墨
顺便说一句,我不确定为什么要将订单与总和相结合-订单不应影响返回的值(除非您应用限制)。