class Page < ActiveRecord::Base
class List < ActiveRecord::Base
######### controller code, inside action:
list = List.find(params[:id])
old_page = list.page
list.page = new_page
# what is the value of old_page now?
old_page now is the same as new_page! what the heck?!?
The only thing i can think of is that old_page is getting assigned some
kind of proxy object, rather than the Page object itself, and
“list.page = new_page” changes only the actual Page object pointed to
by the (same) proxy object. Am I on the right track?
The workaround is easy, of course. But would it really be that hard to
maintain normal object referencing behavior?
Not sure if I’m asking a question or just ranting. But if other people
don’t see this behavior, or if there’s an elegant explanation of why it
has to be this way, then I’d like to know.