提交 c50113bc 编写于 作者: J Jeremy Kemper

create! no longer blows up when no attributes are passed and a :create scope...

create! no longer blows up when no attributes are passed and a :create scope is in effect (e.g. foo.bars.create! failed whereas foo.bars.create!({}) didn't.)

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4348 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 0cd883e1
*SVN*
* create! no longer blows up when no attributes are passed and a :create scope is in effect (e.g. foo.bars.create! failed whereas foo.bars.create!({}) didn't.) [Jeremy Kemper]
* Call Inflector#demodulize on the class name when eagerly including an STI model. Closes #5077 [info@loobmedia.com]
* Preserve MySQL boolean column defaults when changing a column in a migration. Closes #5015. [pdcawley@bofh.org.uk]
......
......@@ -712,6 +712,7 @@ def create!(attributes = nil)
if attributes.is_a?(Array)
attributes.collect { |attr| create!(attr) }
else
attributes ||= {}
attributes.reverse_merge!(scope(:create)) if scoped?(:create)
object = new(attributes)
......
......@@ -88,6 +88,12 @@ def test_invalid_record_exception
end
end
def test_scoped_create_without_attributes
Reply.with_scope(:create => {}) do
assert_raises(ActiveRecord::RecordInvalid) { Reply.create! }
end
end
def test_single_error_per_attr_iteration
r = Reply.new
r.save
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册