EZ_where has_many :through

Given the class definitions:

class Member < ActiveRecord::Base
has_many :assignments, :dependent => :destroy
has_many :projects, :through => :assignments, :uniq => true

end

class Project < ActiveRecord::Base
has_many :assignments, :dependent => :destroy
has_many :members, :through => :assignments, :uniq => true

end

class Assignment < ActiveRecord::Base
belongs_to :member
belongs_to :project

end

I’m trying to construct an EZ_where query that will find members that
have a
given project assignment. Something along the lines of:

members = Member.find(:all, :include => :assignments, :conditions =>
[“assignments.project_id=?”, project])

I’m building the query step by step using statements like:

cond = Caboose::EZ::Condition.new :members do
any {first =~ text_search; last =~ text_search}
end

to create interesting filters. The last piece of the puzzle is to filter
by
project.

Any hints?

TIA


View this message in context:
http://www.nabble.com/EZ_where-has_many-%3Athrough-tf2704391.html#a7540859
Sent from the RubyOnRails Users mailing list archive at Nabble.com.