Module: CarrierWaveDirect::Validations::ActiveModel::HelperMethods
- Defined in:
- lib/carrierwave_direct/validations/active_model.rb
Instance Method Summary collapse
- #validates_filename_format_of(*attr_names) ⇒ Object
-
#validates_filename_uniqueness_of(*attr_names) ⇒ Object
Makes the record invalid if the filename already exists.
- #validates_is_attached(*attr_names) ⇒ Object
- #validates_is_uploaded(*attr_names) ⇒ Object
- #validates_remote_net_url_format_of(*attr_names) ⇒ Object
Instance Method Details
#validates_filename_format_of(*attr_names) ⇒ Object
110 111 112 |
# File 'lib/carrierwave_direct/validations/active_model.rb', line 110 def validates_filename_format_of(*attr_names) validates_with FilenameFormatValidator, _merge_attributes(attr_names) end |
#validates_filename_uniqueness_of(*attr_names) ⇒ Object
Makes the record invalid if the filename already exists
Accepts the usual parameters for validations in Rails (:if, :unless, etc…)
Note
Set this key in your translations file for I18n:
carrierwave_direct:
errors:
filename_taken: 'Here be an error message'
106 107 108 |
# File 'lib/carrierwave_direct/validations/active_model.rb', line 106 def validates_filename_uniqueness_of(*attr_names) validates_with UniqueFilenameValidator, _merge_attributes(attr_names) end |
#validates_is_attached(*attr_names) ⇒ Object
122 123 124 |
# File 'lib/carrierwave_direct/validations/active_model.rb', line 122 def validates_is_attached(*attr_names) validates_with IsAttachedValidator, _merge_attributes(attr_names) end |
#validates_is_uploaded(*attr_names) ⇒ Object
118 119 120 |
# File 'lib/carrierwave_direct/validations/active_model.rb', line 118 def validates_is_uploaded(*attr_names) validates_with IsUploadedValidator, _merge_attributes(attr_names) end |
#validates_remote_net_url_format_of(*attr_names) ⇒ Object
114 115 116 |
# File 'lib/carrierwave_direct/validations/active_model.rb', line 114 def validates_remote_net_url_format_of(*attr_names) validates_with RemoteNetUrlFormatValidator, _merge_attributes(attr_names) end |