mirror of
https://github.com/github/rails.git
synced 2026-01-30 08:48:06 -05:00
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
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Make create! on a has_many :through association return the association object. Not the collection. Closes #8786 [lifofifo]
|
||||
|
||||
* Move from select * to select tablename.* to avoid clobbering IDs. Closes #8889 [dasil003]
|
||||
|
||||
* Don't call unsupported methods on associated objects when using :include, :method with to_xml #7307, [manfred, jwilger]
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -422,7 +422,7 @@ class AssociationsJoinModelTest < Test::Unit::TestCase
|
||||
assert_equal(count + 1, post_thinking.tags.size)
|
||||
assert_equal(count + 1, post_thinking.tags(true).size)
|
||||
|
||||
assert_nothing_raised { post_thinking.tags.create!(:name => 'foo') }
|
||||
assert_kind_of Tag, post_thinking.tags.create!(:name => 'foo')
|
||||
assert_nil( wrong = post_thinking.tags.detect { |t| t.class != Tag },
|
||||
message = "Expected a Tag in tags collection, got #{wrong.class}.")
|
||||
assert_nil( wrong = post_thinking.taggings.detect { |t| t.class != Tagging },
|
||||
|
||||
Reference in New Issue
Block a user