activerecord records not in the :through condition -


i need records not in :through condition.

i have 3 tables:

class < activerecord::base   has_many :b_a   has_many :b, through: :b_a end class b < activerecord::base   has_many :b_a   has_many :a, through: :b_a end class ba < activerecord::base   belongs_to :a   belongs_to :b end 

i linked specific b listofa = b.a need not in b. how can ?

ok, had 2 conditions put in join query. mysql :

select a.`id`, a.`label` `a` left join `ba` ba on a.`id` = ba.`a` a.`uid`='userid' , ba.`a` null 

my activerecord :

a.select(['a.id', :label])   .joins('left outer join b_a on b_a.a_id = a.id')   .where({ user_id: current_user.id, "b_a.a_id" => nil }) 

and have not in ba


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -