Rails 3.2.11
My app has a model called Plan, which has has_many self-referential association just like
has_many :matches has_many :counterparts, :through => :matches has_many :inverse_matches, :class_name => "Match", :foreign_key => :counterpart_id has_many :inverse_counterparts, :through => :inverse_matches, :source => :plan
and in the plans_controller, I would like to find a plan (counterpart) having many conditions.
plans = Plan.arel_table @counterpart = Plan.where( .... ).where( plans[:user_id].not_eq(current_user.id) # eliminate current user )
in addition to this, I need one more condition. That is
A Plan (counterpart) which has yet been found by any plans. It should look like
counterpart.matches.length == 0
How can I add this condition to the where clauses describe above?
thanks!
soichi