I ran into unusual things in the ActiveRecord #relationship_ids method (which is automatically added when the has_many declaration), which is immediately saved for existing entries, which causes me some problems, and I am wondering if anyone has any useful tips.
I am running Rails 2.3.5.
Consider this simple scenario in which the article has_many tags, say:
a = Article.first
a.name = "New Name" # No save yet
a.author_id = 1 # No save yet
a.tag_ids = [1,2,3] # These changes are saved to the database
This seems surprising to me. This, in particular, causes problems when trying to create a preview tool - I want to update a bunch of attributes and then view the article without saving it, but in this case the tag changes are saved, although no other fields do.
(, "" - , , , , - , "a.save" )
- tag_ids = , before_save.
, has_many , .
- - / / ? !