Question updating linked records

i dont think its a bug.

did you try this:

rate = Rate.find(1) puts rate.currency_id = 2 puts

That *should* work. And it makes sense that it works like this. Otherwise you could *forget* to actually update the record in the table, and get strange bugs. Rails forces you to save the changed record so the tables stay in sync with your changes ...

That's how i see it.

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 Quote:

"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.

EndofQuote so something like this should work, not tested though

rate = Rate.find(1) puts rate.currency_id = 2 rate.currency(true) puts