Forum: Ruby on Rails Little Rails Bug - does it still exist?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Nex (Guest)
on 2007-07-26 20:07
(Received via mailing list)
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
Jason R. (Guest)
on 2007-07-26 20:09
(Received via mailing list)
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 =>

Nex (Guest)
on 2007-07-26 20:15
(Received via mailing list)
Ah fantastic - thanks (new to Ruby and Rails).

Cheers for the info,

- Nex
This topic is locked and can not be replied to.