Sprite,
I propose a small change. Add a space between the sql_query string and the
@top_tippers variable (for readability sake):
def top_tippers
sql_query = "SELECT top_tippers.total_tips AS total_tips,
top_tippers.client_id AS client_id,
users.login_slug AS login_slug,
users.login AS login
FROM (
SELECT SUM(tips.amount_cents) AS total_tips,
tips.client_id AS client_id
FROM tips
WHERE tips.vendor_id = #{self.id}
GROUP BY tips.client_id
ORDER BY total_tips DESC) AS top_tippers, users
WHERE top_tippers.client_id = users.id"
@top_tippers = User.find_by_sql(sql_query)
end
And this blog post may be helpful too as you code: Top 10 Things That Annoy
Programmers<http://www.kevinwilliampang.com/2008/08/28/top-10-things-that-annoy-programmers/>
.
Regards,
---
Edmond
Software Developer | Baobab Health Trust (http://www.baobabhealth.org/) |
Malawi
Cell: +265 999 465 137 | +265 881 234 717
*"Many people doubt open source software and probably don’t realize that
there is an alternative… which is just as good.." -- Kevin Scannell*
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.