Class: CarrierWaveDirect::Validations::ActiveModel::UniqueFilenameValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- CarrierWaveDirect::Validations::ActiveModel::UniqueFilenameValidator
- Defined in:
- lib/carrierwave_direct/validations/active_model.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/carrierwave_direct/validations/active_model.rb', line 13 def validate_each(record, attribute, value) if record.new_record? && record.errors[attribute].empty? && (record.send("has_#{attribute}_upload?") || record.send("has_remote_#{attribute}_net_url?")) if record.class.where(attribute => record.send(attribute).filename).exists? record.errors.add(attribute, :carrierwave_direct_filename_taken) end end end |