Sha256: 1d782d1aa572655be05daa99571d46a1dfe030075f8e154f0d0279cadcebd807
Contents?: true
Size: 775 Bytes
Versions: 36
Compression:
Stored size: 775 Bytes
Contents
require 'active_model/validations/presence' module Polygallery module Validators class PolygalleryPresenceValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if record.send(attribute).present? unless record.send(attribute).photos.any? record.errors.add(attribute, :blank, options) end else record.errors.add(attribute, :blank, options) end end def self.helper_method_name :validates_polygallery_presence end end module HelperMethods def validates_polygallery_presence(*attr_names) options = _merge_attributes(attr_names) validates_with PolygalleryPresenceValidator, options.dup end end end end
Version data entries
36 entries across 36 versions & 1 rubygems