Pergunta

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 ?

Foi útil?

Solução

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")

Outras dicas

You can do polymorphic belongs to like as follows

Note.joins{notable(Person).outer}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top