SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: find with order sum
-
Nov 7, 2007, 12:02 #1
- Join Date
- Sep 2006
- Posts
- 62
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
find with order sum
I have 2 models:
class Core < ActiveRecord::Base
has_many :votes
end
class Vote < ActiveRecord::Base
belongs_to:core
end
the model Vote has the vote attribute with -1,0,1 values
I want to get the list of Cores (name,vote) with top vote.
es.
cores.name votes
p 32
aaa 10
two 9
three 8
hello 6
aaaa 5
rrrr 4
qqqq 3
ccc -4
eww -10
I want to do it with a only query. (like i did it with php)
How can i do??
Thanks.
-
Nov 8, 2007, 09:12 #2
This should give you a few ideas:
http://api.rubyonrails.org/classes/A...ssMethods.html
-
Nov 11, 2007, 08:33 #3
- Join Date
- Sep 2006
- Posts
- 62
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanks but now in list i must view also the number of comments.
then
cores.name votes comments
how i can do?
Bookmarks