Gus Higuera
Gus Higuera

Reputation: 95

Ordering thumbs up results by vote count

Still a rails newbie, trying to order the following list by the sum of votes_for+votes_against on subitems, with thumbs_up the votes live in another table though

@subitems = @items.subitems

Upvotes: 1

Views: 205

Answers (1)

Pent
Pent

Reputation: 1049

You should use:

@items = Item.plusminus_tally({:order => "vote_count ASC"})

I included the order override in there, in case you wanted to change it from the default of descending order. This is for Rails 3.

A subitem should have it's own:

acts_as_voteable

in its model.

Upvotes: 1

Related Questions