Forum: Ruby on Rails Why the record is updated?

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.
2f24c382600d9fd71085a74251fd5a39?d=identicon&s=25 Damian Terentyev (Guest)
on 2007-03-03 08:03
(Received via mailing list)
Hi, all!
I have the following problem:
Suppose I have a post that has and belongs to many tags.
If I do e.g.

my_post.title = "New title"

I still need to do

to write changes to the database
But if I do

my_post.tags = [some_tag, some_other_tag]

the changes seem to be written down right there.
Isn't it a bug?
This kind of behaviour is undesired for me because I wish to check
before_update which tags were added and removed to perform some
manipulations with them. And if I do

my_post.update_attributes(:tags => new_list_of_tags)

in before_update changes are actually already been saved so I can't get
the old tags at all.

Any help will be appreciated.

Yours sincerely,
Damian/Three-eyed Fish
This topic is locked and can not be replied to.