its no bug. in his second example, he did not load the associated
records before changing the primary key, so they weren't cached, but
retrieved from the database.
However, i think my argumentation from the previous post is not really
solid, but i think i just just found the solution.
It's all in the API docs.
See rails API FOR: ActiveRecord::Associations::ClassMethods
"Adds the following methods for retrieval and query for a single
associated object that this object holds an id to. association is
replaced with the symbol passed as the first argument, so belongs_to
:author would add among others author.nil?. "
- association(force_reload = false) - returns the associated object.
Nil is returned if none is found.
so something like this should work, not tested though
rate = Rate.find(1)
rate.currency_id = 2