#14 Performing Calculations on Models

Task.sum(:priority)
Task.sum(:priority, :conditions => 'complete=0')
Task.maximum(:priority)
Task.minimum(:priority)
Task.average(:priority)
p = Project.find(:first)
p.tasks.sum(:priority)
p.tasks.sum(:priority, :conditions => 'complete=0')

你可能感兴趣的:(Ruby,Rails)