aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/validations/presence.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/validations/presence.rb')
-rw-r--r--activerecord/lib/active_record/validations/presence.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/validations/presence.rb b/activerecord/lib/active_record/validations/presence.rb
index 7e85ed43ac..e34d2d70ab 100644
--- a/activerecord/lib/active_record/validations/presence.rb
+++ b/activerecord/lib/active_record/validations/presence.rb
@@ -2,7 +2,7 @@ module ActiveRecord
module Validations
class PresenceValidator < ActiveModel::Validations::PresenceValidator # :nodoc:
def validate_each(record, attribute, association_or_value)
- return unless should_validate?(record)
+ return unless should_validate?(record) || unknown_attribute?(record, attribute)
if record.class._reflect_on_association(attribute)
association_or_value = Array.wrap(association_or_value).reject(&:marked_for_destruction?)
end