How can I do something like "select candidates.*, count(votes.id) from candidates join votes ON(candidates.id = votes.candidate.id) group by candidates.id" in ActiveRecord, and get Candidate models back, with a "votes" field?
rhizome: "SELECT candidates.*, count(votes.id) from candidates LEFT JOIN votes ON(candidates.id = votes.id) GROUP BY candidates.id;" gives me back, in SQL, exactly what I want for data.
It gives me candidate fields, and gives me a count of votes for each candidate.
How do I turn that into AR invocations to get candidate models and that calculated field?
rhizome: Yes. I can get all candidats. And I could loop over all them, and get counts of votes on each. That is lame, since that means I have n+1 queries, where n is the number of candidates.
Are you cancelling the event, and turning the button unpressable?
oh. If it's a POST, is it an OPTIONS request followed by the POST? Or is it really POST twice?
sinclair: jquery ujs is handling it with remote=>true, and you're not doing anything with js apart from that? Is there an HTTP->HTTPS upgrade happening? Do both requests return 200/201?
Alternate option is routing /:company/:message to /:company and having a js handler on that page that parses the /:message to go to that anchor.
I take no responsibility for strangling that may happen to you in that scenario.