Little Rails Bug - does it still exist?


I came across a little Rails gotcha recently, something that was
reported back at least a year ago. I was wondering whether anyone
could help me find my way through the bug tracker and see if there was
progress on it (I am new to Rails).

Here is the bug:

You cannot go through a :through association and set a field like

paper1.relations_as_source.find_by_id(1).note = “Something”
That will return ok, but NOT GET SET!

You have to have an intermediary variable first:

rel = paper1.relations_as_source.find_by_id(1)
rel.note = “Something”

I would like to ask whether anyone knew the background to this bug (is
this intended to work this way, and if so, why?) but of course this
may be covered in the bug-tracker, so if anyone can help me find it,
that would be great as I’d like to keep tabs on this one.

Many many thanks,

  • Nex


Not a bug. The var= operator does not save information to the database,
your first line is basically wasted resources. You want:

paper1.relations_as_source.find_by_id(1).update_attributes(:note =>



Ah fantastic - thanks (new to Ruby and Rails).

Cheers for the info,

  • Nex