Question

I am using acts_as_votable for my questions/answers application. Each question and each answer can be voted (à la stack overflow).

I am using squeel and looking for a way to get the following : order the questions from the most voted to the less voted ; and for each question, order the answers from the most voted to the less voted.

What should be the best squeel query for that ?

Was it helpful?

Solution

The best way to do this type of query is to use the cache system described in the main page of acts_as_votable and then perform this request : Question.order("cached_votes_up desc")

OTHER TIPS

You can do polymorphic belongs to like as follows

Note.joins{notable(Person).outer}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top