title: Query - Ruby on Rails
body: <p>I don't have knowledge of Rails</p>
  
  <p>Please, how do I make this query in Rails?</p>
  
  <pre><code>SELECT *, count(v.id) numero_votos FROM ideas i left join votes v on v.idea_id = i.id group by i.id order by numero_votos desc, i.created_at
  </code></pre>
  
  <p>I tried this...</p>
  
  <pre><code>@listOfIdeas = Idea.find(:all, joins: "LEFT JOIN 'votes' on votes.idea_id = ideas.id",
                                      select: "ideas.*, count(votes.id) numero_de_votos",
                                      group: "ideas.id",
                                      order: "numero_de_votos DESC, ideas.created_at DESC")
  </code></pre>
  
  <p>But, didn't work, it's showing me this message:</p>
  
  <blockquote>
    <p>Couldn't find all Ideas with 'id': (all, {:joins=>"LEFT JOIN 'votes' on votes.idea_id = ideas.id", :select=>"ideas.*, count(votes.id) numero_de_votos", :group=>"ideas.id", :order=>"numero_de_votos DESC, ideas.created_at DESC"}) (found 0 results, but was looking for 2)</p>
  </blockquote>
  
  <p>Rails version: 5.1.4</p>
  
  <p>Thanks!</p>