aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-02-14 23:14:42 +0000
committerJon Leighton <j@jonathanleighton.com>2011-02-18 00:00:13 +0000
commit91fd6510563f84ee473bb217bc63ed598abe3f24 (patch)
tree8d9a4996e5a7b9663e8bd7869d62c9701e5385de /activerecord/CHANGELOG
parentf0b98050296b57d95dbc789f8e52fa82499d151a (diff)
downloadrails-91fd6510563f84ee473bb217bc63ed598abe3f24.tar.gz
rails-91fd6510563f84ee473bb217bc63ed598abe3f24.tar.bz2
rails-91fd6510563f84ee473bb217bc63ed598abe3f24.zip
Allow building and then later saving has_many :through records, such that the join record is automatically saved too. This requires the :inverse_of option to be set on the source association in the join model. See the CHANGELOG for details. [#4329 state:resolved]
Diffstat (limited to 'activerecord/CHANGELOG')
-rw-r--r--activerecord/CHANGELOG24
1 files changed, 24 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 72bbeeec61..e434372fb7 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,29 @@
*Rails 3.1.0 (unreleased)*
+* Make has_many :through associations work correctly when you build a record and then save it. This
+ requires you to set the :inverse_of option on the source reflection on the join model, like so:
+
+ class Post < ActiveRecord::Base
+ has_many :taggings
+ has_many :tags, :through => :taggings
+ end
+
+ class Tagging < ActiveRecord::Base
+ belongs_to :post
+ belongs_to :tag, :inverse_of => :tagging # :inverse_of must be set!
+ end
+
+ class Tag < ActiveRecord::Base
+ has_many :taggings
+ has_many :posts, :through => :taggings
+ end
+
+ post = Post.first
+ tag = post.tags.build :name => "ruby"
+ tag.save # will save a Taggable linking to the post
+
+ [Jon Leighton]
+
* Support the :dependent option on has_many :through associations. For historical and practical
reasons, :delete_all is the default deletion strategy employed by association.delete(*records),
despite the fact that the default strategy is :nullify for regular has_many. Also, this only