aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/validations.rb
diff options
context:
space:
mode:
authorTobias Lütke <tobias.luetke@gmail.com>2006-12-06 00:13:31 +0000
committerTobias Lütke <tobias.luetke@gmail.com>2006-12-06 00:13:31 +0000
commitcdad2d41e18977dd66518efddcb83c2107f0e057 (patch)
treebc7b29ec491f534cd2ca91385658d404e3382452 /activerecord/lib/active_record/validations.rb
parent8dea60b0c3a965c169127e0f1f4777bfbbc5e16d (diff)
downloadrails-cdad2d41e18977dd66518efddcb83c2107f0e057.tar.gz
rails-cdad2d41e18977dd66518efddcb83c2107f0e057.tar.bz2
rails-cdad2d41e18977dd66518efddcb83c2107f0e057.zip
Consolidated different create and create! versions to call through to the base class with scope. This fixes inconsistencies, especially related to protected attribtues.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5684 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/validations.rb')
-rwxr-xr-xactiverecord/lib/active_record/validations.rb6
1 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index 3bc0e8fa37..342a4844cc 100755
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -717,12 +717,10 @@ module ActiveRecord
# so an exception is raised if the record is invalid.
def create!(attributes = nil)
if attributes.is_a?(Array)
- attributes.collect { |attr| create!(attr) }
+ attributes.collect { |attr| create(attr) }
else
- attributes ||= {}
- attributes.reverse_merge!(scope(:create)) if scoped?(:create)
-
object = new(attributes)
+ scope(:create).each { |att,value| object.send("#{att}=", value) } if scoped?(:create)
object.save!
object
end