#14
Apr 04, 2007

Performing Calculations on Models

Did you know ActiveRecord provides class methods for performing calculations on models? You can even use these methods through associations.
Download (11.7 MB, 2:57)
alternative download for iPod & Apple TV (3.9 MB, 2:57)
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')

RSS Feed for Episode Comments 20 comments

1. santosh Aug 01, 2007 at 01:59

This is very use ful for new programmers who doing their projects in ROR...
So keep sending comments and what u nw ,u should share with ur thoughts with others and would be better for improving our knowledge....So Keep sending wt u know ..and learn wt u wt u dont no by this format........
And one more thing i want to tel u is please send some material on ROR to my mail.......
OK Thanks,
Santosh


2. omfg Aug 02, 2007 at 13:33

Hey, you forgot to put your email here so I can send you some info on "ROR".


3. Joe Grossberg Aug 07, 2007 at 08:40

Next railscast: how to leave comments that don't make you look like a semi-literate teenager.


4. Matt Grande Apr 14, 2008 at 15:57

What's that funky thing showing your SQL in the background?


5. roller8 Apr 28, 2008 at 22:26

@Matt: I think you're referring to "tailing the development log". It's a technique for watching what's getting written to the log in real time.


6. lajunta Oct 18, 2008 at 22:04

Very good tutorial..Thank you, Ryan.


7. Gucci Kitbags Nov 13, 2009 at 19:59

Gucci shoes claim to desigh their shoes ‘‘from inside out’’and in this image of the heeled version of their 3-tiered Soleplex design,you begin to see why.In this image,tiers 1 and 2 make up the ‘‘Footbed and Stabilizer’’level.


8. eq2 plat Dec 17, 2009 at 00:52

good post!


9. ghd for sale Dec 29, 2009 at 00:36

GHD creates different and beautiful hairstyles . ghd straighteners is designed specially for those beautiful girls who want to be more sexy and charming. So if you want to be more attractive,it is a proper choice for you .


10. herve leger sale Dec 29, 2009 at 00:37

 A new kind of dress coe into being-herve leger dress.And all oh this herve leger bandages look so elegance and charming,have you fall in love with it?


11. wow cd key Jan 11, 2010 at 20:47

good news


12. wholesale nike shoes Jan 13, 2010 at 23:26

A very good article, I will always come in.


13. fashion scarves Jan 13, 2010 at 23:26

Such a good article, caught my sympathy!
-


14. 婚紗照 Feb 05, 2010 at 10:33

it's very good , i love it. by the way,


15. 婚紗攝影 Feb 05, 2010 at 10:34

cool. very good.


16. cheap picture frames Feb 22, 2010 at 22:34

Your page definitely was one of the top points of my weekend.


17. 2366 Mar 02, 2010 at 23:24

it's very good , i love it. by the way,


18. 小花仙 Mar 02, 2010 at 23:25

i will post other comment.


19. 弹弹堂 Mar 02, 2010 at 23:43

this is another comment!


20. Louis Vuitton handbags Mar 09, 2010 at 18:41

railscasts.com/episodes/14-performing-calculations-on-models

Add your comment:

(SKIP THIS ONE)

(required)

(not shown)


(use pastie or gist for code)

sponsored by:
if you want to help:
required:
Get Quicktime Player
Give Back to Open Source