I asked this in a different form some weeks ago and got no response,
let me try again in hopes that I can make my question clearer.
Let’s say I have the following models
class Author < ActiveRecord::Base
has_many :signings
end
class Signing < ActiveRecord::Base
belongs_to: :author
Has an attribute when, which is a DateTime
end
Now what I want to do is find all authors who have at least one
signing scheduled on or after a particular date. In other words, I
want to exclude authors who won’t be signing on or after that date.
Since I don’t have a black belt in SQL, I’m not sure how to do this.
I think I want some kind of join of authors to signings, and a query
which groups by author and a where clause involving the maximum value
of where for each signing in the group. But I’m having a hard time
visualizing the actual SQL for this.
And for extra points, is there a way to do this with find, :include
=>, :conditions, rather than find_by_sql?
–
Rick DeNatale
My blog on Ruby
http://talklikeaduck.denhaven2.com/