Sha256: 34b6a14be26bc9580bf0e2a1e10b29add14e41038790cc34e1474ba96df647cc
Contents?: true
Size: 518 Bytes
Versions: 2
Compression:
Stored size: 518 Bytes
Contents
module ValidatesAsImage def self.included receiver receiver.extend ClassMethods end module ClassMethods def validates_as_image fields validates_each fields do |record, attr, value| if !value.queued_for_write.empty? and value.to_file `identify "#{value.to_file.path}"` record.errors.add attr, I18n.t("activerecord.errors.models.#{record.class.table_name.singularize}.attributes.#{attr}.wrong_format") unless $? == 0 end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
merrycms-0.1.7 | lib/merrycms/validates_as_image.rb |
merrycms-0.1.4 | lib/merrycms/validates_as_image.rb |