Hopefully the subject is clear enough.
Let's say I've got two tables:
create_table :bands do | b |
b.column :name, :string
create_table :concerts do | c |
c.column :where, :string
c.column :when, :date
c.column :band_id, :integer
and the models:
class Band <<ActiveRecord::Base
class Concert << ActiveRecord::Base
What I'd like to do is find all of the Bands which have at least one
concert on or after a given date.
In this case there are lots of concerts which makes this a bit
I've not been able to figure out how to do this through ActiveRecord
so as to generate an efficient SQL query, or how to do it manually
using find_by_sql either. It's a bit complicated also since SQL date
comparison function seems to be somewhat database dependent.
Any ideas from the community?