Browse files

merge from trunk (include Enumerable in AR::Errors, make Validations#…

…create! use current scope)

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/stable@2988 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent ce6545e commit e823ef8336d977c459afe72cbb8e3f6f2013a326 @jamis jamis committed Nov 12, 2005
Showing with 6 additions and 0 deletions.
  1. +2 −0 activerecord/CHANGELOG
  2. +4 −0 activerecord/lib/active_record/validations.rb
View
2 activerecord/CHANGELOG
@@ -2,6 +2,8 @@
* SQLServer: don't report limits for unsupported field types. #2835 [Ryan Tomayko]
+* Include the Enumerable module in ActiveRecord::Errors. [Rick Bradley <rick@rickbradley.com>]
+
* Add :group option, correspond to GROUP BY, to the find method and to the has_many association. #2818 [rubyonrails@atyp.de]
* Don't cast nil or empty strings to a dummy date. #2789 [Rick Bradley <rick@rickbradley.com>]
View
4 activerecord/lib/active_record/validations.rb
@@ -17,6 +17,8 @@ def initialize(record, *args)
# Active Record validation is reported to and from this object, which is used by Base#save to
# determine whether the object in a valid state to be saved. See usage example in Validations.
class Errors
+ include Enumerable
+
def initialize(base) # :nodoc:
@base, @errors = base, {}
end
@@ -658,6 +660,8 @@ def create!(attributes = nil)
if attributes.is_a?(Array)
attributes.collect { |attr| create!(attr) }
else
+ attributes.reverse_merge!(scope(:create)) if scoped?(:create)
+
object = new(attributes)
object.save!
object

0 comments on commit e823ef8

Please sign in to comment.