p = Person.find(:first)
p.school # nil
p.school_id = School.find_by_name('High School').id
p.school.name # High School

You should be assigning .school= here.  Why are you working with the id?

p.school_id = School.find_by_name('Primary School').id
p.school.name # High School <= Shouldn't this be Primary School?
p.school.id == p.school_id # false !!!

Again, the .school_id accessors aren't really meant for use like this.
I  suppose the accessors could check the ids,  but it seems like a lot
of work for a corner case.   An alternative would be to let the
school_id accessor use school.id  if the proxy's been loaded.
--
Cheers

Koz
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to