From 816522ecd8615bf96e8b932ac358fe9346b286ee Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Wed, 11 Jul 2007 23:54:43 +0000 Subject: 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 --- .../lib/active_record/associations/has_many_through_association.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/associations') 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 -- cgit v1.2.3