aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-12-26 19:05:03 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-12-26 19:05:03 -0300
commit93366c7c913bf0883f140fa782d3e198593477be (patch)
tree485791ef8b3bbc02ba9e4a37533261329c0d785c /activemodel/lib
parent8c938dddd22f16e2e15471a648aaa96be380c562 (diff)
downloadrails-93366c7c913bf0883f140fa782d3e198593477be.tar.gz
rails-93366c7c913bf0883f140fa782d3e198593477be.tar.bz2
rails-93366c7c913bf0883f140fa782d3e198593477be.zip
Fix `validates_presence_of` with `:allow_nil` or `:allow_blank` options.
Fix #8621 [Colin Kelley + Rafael Mendonça França]
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/validations/presence.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/validations/presence.rb b/activemodel/lib/active_model/validations/presence.rb
index efd1372a6b..20a57e3c59 100644
--- a/activemodel/lib/active_model/validations/presence.rb
+++ b/activemodel/lib/active_model/validations/presence.rb
@@ -4,8 +4,8 @@ module ActiveModel
# == Active Model Presence Validator
module Validations
class PresenceValidator < EachValidator
- def validate(record)
- record.errors.add_on_blank(attributes, options)
+ def validate_each(record, attr_name, value)
+ record.errors.add(attr_name, :blank, options) if value.blank?
end
end
@@ -39,7 +39,7 @@ module ActiveModel
# if the validation should not occur (e.g. <tt>:unless => :skip_validation</tt>,
# or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The method,
# proc or string should return or evaluate to a true or false value.
- # * <tt>:strict</tt> - Specifies whether validation should be strict.
+ # * <tt>:strict</tt> - Specifies whether validation should be strict.
# See <tt>ActiveModel::Validation#validates!</tt> for more information.
def validates_presence_of(*attr_names)
validates_with PresenceValidator, _merge_attributes(attr_names)