-
-
Save peteonrails/141505 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tally(options = {}) | |
find(:all, options_for_tally(options.merge({:order =>"count DESC" }))) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> s1 = Status.tally({ | |
?> :at_least => 1, | |
?> :order => 'status.created_at desc' }) # DESC | |
>> s2 = Status.tally({ | |
?> :at_least => 1, | |
?> :order => 'status.created_at asc' }) # ASC | |
>> s1[0].created_at == s2[0].created_at | |
=> true | |
>> s1.each {|x| puts x.votes_count} | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
>> s2.each {|x| puts x.votes_count} | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment