aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/CHANGELOG.md2
-rw-r--r--activemodel/README.rdoc2
-rw-r--r--activemodel/lib/active_model/validations.rb15
-rw-r--r--activemodel/test/cases/secure_password_test.rb2
4 files changed, 11 insertions, 10 deletions
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md
index 2c966943ee..aa42bf762f 100644
--- a/activemodel/CHANGELOG.md
+++ b/activemodel/CHANGELOG.md
@@ -76,6 +76,6 @@
* Trim down Active Model API by removing `valid?` and `errors.full_messages` *José Valim*
-* When `^` or `$` are used in the regular expression provided to `validates_format_of` and the :multiline option is not set to true, an exception will be raised. This is to prevent security vulnerabilities when using `validates_format_of`. The problem is described in detail in the Rails security guide.
+* When `^` or `$` are used in the regular expression provided to `validates_format_of` and the :multiline option is not set to true, an exception will be raised. This is to prevent security vulnerabilities when using `validates_format_of`. The problem is described in detail in the Rails security guide *Jan Berdajs + Egor Homakov*
Please check [3-2-stable](https://github.com/rails/rails/blob/3-2-stable/activemodel/CHANGELOG.md) for previous changes.
diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc
index b4565b5881..fc34d69ff6 100644
--- a/activemodel/README.rdoc
+++ b/activemodel/README.rdoc
@@ -23,7 +23,7 @@ to integrate with Action Pack out of the box: <tt>ActiveModel::Model</tt>.
validates_presence_of :name
end
- person = Person.new(:name => 'bob', :age => '18')
+ person = Person.new(name: 'bob', age: '18')
person.name # => 'bob'
person.age # => '18'
person.valid? # => true
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb
index 4762f39044..9e6ec17ce1 100644
--- a/activemodel/lib/active_model/validations.rb
+++ b/activemodel/lib/active_model/validations.rb
@@ -3,6 +3,7 @@ require 'active_support/core_ext/hash/keys'
require 'active_support/core_ext/hash/except'
require 'active_model/errors'
require 'active_model/validations/callbacks'
+require 'active_model/validator'
module ActiveModel
@@ -188,9 +189,9 @@ module ActiveModel
# # #<ActiveModel::Validations::InclusionValidator:0x007fe603bb8780 @attributes=[:age], @options={:in=>0..99}>
# # ]
def validators_on(*attributes)
- attributes.map do |attribute|
+ attributes.flat_map do |attribute|
_validators[attribute.to_sym]
- end.flatten
+ end
end
# Returns +true+ if +attribute+ is an attribute method, +false+ otherwise.
@@ -233,7 +234,7 @@ module ActiveModel
#
# person = Person.new
# person.valid? # => false
- # person.errors # => #<ActiveModel::Errors:0x007fe603816640 @messages={:name=>["can't be blank"]}>
+ # person.errors # => #<ActiveModel::Errors:0x007fe603816640 @messages={:name=>["can't be blank"]}>
def errors
@errors ||= Errors.new(self)
end
@@ -250,7 +251,7 @@ module ActiveModel
#
# person = Person.new
# person.name = ''
- # person.valid? # => false
+ # person.valid? # => false
# person.name = 'david'
# person.valid? # => true
#
@@ -265,7 +266,7 @@ module ActiveModel
# end
#
# person = Person.new
- # person.valid? # => true
+ # person.valid? # => true
# person.valid?(:new) # => false
def valid?(context = nil)
current_context, self.validation_context = validation_context, context
@@ -287,7 +288,7 @@ module ActiveModel
#
# person = Person.new
# person.name = ''
- # person.invalid? # => true
+ # person.invalid? # => true
# person.name = 'david'
# person.invalid? # => false
#
@@ -302,7 +303,7 @@ module ActiveModel
# end
#
# person = Person.new
- # person.invalid? # => false
+ # person.invalid? # => false
# person.invalid?(:new) # => true
def invalid?(context = nil)
!valid?(context)
diff --git a/activemodel/test/cases/secure_password_test.rb b/activemodel/test/cases/secure_password_test.rb
index 19e74d3cc9..509e2fdbb5 100644
--- a/activemodel/test/cases/secure_password_test.rb
+++ b/activemodel/test/cases/secure_password_test.rb
@@ -55,7 +55,7 @@ class SecurePasswordTest < ActiveModel::TestCase
end
test "User should not be created with blank digest" do
- assert_raise RuntimeError do
+ assert_raise RuntimeError do
@user.run_callbacks :create
end
@user.password = "supersecretpassword"