Hello all,
i found something wrong (or maybe i was wrong?)
this looks like a rectiverecord bug , can anyone help me to point
out what’s going on?
------------------migration
create_table :books do |t|
t.column :name,:string
t.column :person_id,:integer
end
create_table :people do |t|
t.column :name ,:string
end
------------------model
class Book < ActiveRecord::Base
belongs_to :person
end
class Person < ActiveRecord::Base
has_many :books
end
------------------in console , try the following:
book=Book.create(:name=>‘book1’)
kevin=Person.create(:name=>‘kevin’)
kevin.books # should be empty []
book.person=kevin
book.save
kevin.books # why still nothing ???
Person.find(kevin.id).books # have books!