diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-07-11 23:54:43 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-07-11 23:54:43 +0000 |
commit | 816522ecd8615bf96e8b932ac358fe9346b286ee (patch) | |
tree | ce3aeee6243bfb04b9e3ad1743734b33cbf74bdd /activerecord/lib | |
parent | d4d4a08f6b064e47145b1abaca803654957f7a03 (diff) | |
download | rails-816522ecd8615bf96e8b932ac358fe9346b286ee.tar.gz rails-816522ecd8615bf96e8b932ac358fe9346b286ee.tar.bz2 rails-816522ecd8615bf96e8b932ac358fe9346b286ee.zip |
Make create! on a has_many :through association return the association object. Not the collection. Closes #8786 [lifofifo]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7182 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_through_association.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb index 7a55334912..b75de4d23f 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -91,7 +91,8 @@ module ActiveRecord def create!(attrs = nil) @reflection.klass.transaction do - self << @reflection.klass.send(:with_scope, :create => attrs) { @reflection.klass.create! } + self << (object = @reflection.klass.send(:with_scope, :create => attrs) { @reflection.klass.create! }) + object end end |