Strange behaviour of `has_many through` associations

13 views
Skip to first unread message

Roman

unread,
Feb 27, 2013, 7:46:00 AM2/27/13
to rubyonra...@googlegroups.com
class Member < ActiveRecord::Base
  has_many :contact_references
  has_many :contacts, through: :contact_references # contacts are of class Member
end

m1 = Member.new
m2 = Member.new

m1.contacts.include? m2 # => false
m1.contacts << m2
m1.contacts.delete m2
m1.contacts # => []
m1.contacts.include? m2 # => true

W00t?
Reply all
Reply to author
Forward
0 new messages