Forum: Ruby on Rails Strange behaviour of `has_many through` associations

Posted by Roman (Guest)
on 2013-02-27 13:47
(Received via mailing list)
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?
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.