If you can use find_by_sql try this:
Stream.find_by_sql(
["select streams.* from streams join
(select stream_id, count(*) from postings
where created_at > :one_day_ago
group by stream_id
order by count(*) desc) subq
on streams.id = subq.stream_id ",
{:one_day_ago=>1.day.ago}]
)
Bad thing is you can't programmatically do much with it in terms of
adding limit statements, etc, but if it solves the problem, use it.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---