I think there is a slight inconsistency in Rails regarding adding 
associations between existing records.

Assume Post has_many :tags.

We have an analogy when we want to immediately add the association to 
either new or existing child:

> Post.first.tags.create name: "my tag" # commits immediately
> # and to existing tag
> Post.first.tags << Tag.first # commits immediately


But we don't have an analogy to build:

> p = Post.first
> p.tags.build name: "my tag"
> p.save # commits all changes
> # and to existing tag
> # ?


I think this is unfortunate, because I like the idea of building all 
changes in memory first and then commiting everything together. I have a 
project where this would be useful for me, but is currently not possible. 
Why not? Discuss.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/2H7Bo9y1t10J.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to