Sha256: 3740601319b5c9d5e6f8bdba594c237aa3ff987ba691336d71ff422d2a498ae9

Contents?: true

Size: 348 Bytes

Versions: 78

Compression:

Stored size: 348 Bytes

Contents

class AssetBoxPresenceValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    num_in_box = (record.attachments || []).select { |attachment| attachment.box == attribute.to_s.pluralize && attachment.marked_for_destruction? == false }.size
    record.errors[attribute] << "can't be blank" if num_in_box == 0
  end
end

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
effective_assets-1.12.2 lib/validators/asset_box_presence_validator.rb
effective_assets-1.12.1 lib/validators/asset_box_presence_validator.rb
effective_assets-1.12.0 lib/validators/asset_box_presence_validator.rb
effective_assets-1.11.5 lib/validators/asset_box_presence_validator.rb
effective_assets-1.11.4 lib/validators/asset_box_presence_validator.rb
effective_assets-1.11.3 lib/validators/asset_box_presence_validator.rb
effective_assets-1.11.2 app/models/validators/asset_box_presence_validator.rb
effective_assets-1.11.1 app/models/validators/asset_box_presence_validator.rb
effective_assets-1.11.0 app/models/validators/asset_box_presence_validator.rb
effective_assets-1.10.1 app/models/validators/asset_box_presence_validator.rb
effective_assets-1.10.0 app/models/validators/asset_box_presence_validator.rb
effective_assets-1.9.14 app/models/validators/asset_box_presence_validator.rb
effective_assets-1.9.13 app/models/validators/asset_box_presence_validator.rb
effective_assets-1.9.12 app/models/validators/asset_box_presence_validator.rb
effective_assets-1.9.11 app/models/validators/asset_box_presence_validator.rb
effective_assets-1.9.10 app/models/validators/asset_box_presence_validator.rb
effective_assets-1.9.9 app/models/validators/asset_box_presence_validator.rb
effective_assets-1.9.8 app/models/validators/asset_box_presence_validator.rb
effective_assets-1.9.7 app/models/validators/asset_box_presence_validator.rb
effective_assets-1.9.6 app/models/validators/asset_box_presence_validator.rb