Class: ActiveRecord::Validations::AssociationNotSoftDestroyedValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/paranoia.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



318
319
320
321
322
323
# File 'lib/paranoia.rb', line 318

def validate_each(record, attribute, value)
  # if association is soft destroyed, add an error
  if value.present? && value.deleted?
    record.errors[attribute] << 'has been soft-deleted'
  end
end