Hi everybody, here is my problem.
I have a Post model, a Tag model, and they are related to each other by an has_and_belongs_to_many relationship.
Now I run ./script/console:
p=Post.new p.title="Hello" p.save
t=Tag.new t.name="tag1" p.tags = [t]
The result is that a Post record is created and saved, and then also a Tag record is created and saved, together with a record in the join table posts_tags. The question is: why are the tag and the record in the join table saved? Shouldn't they wait for an explicit save? To be more clear, why the last line ( p.tags=[t] ) triggers the creation in the database of a record in the tags table and another in the posts_tags table? Is there a way from stopping this until an explicit save occurs?
I hope someone can answer my question, I'm quite a rails newbie so I need help. Thanks.