1 class SyncVhValidator < ActiveModel::EachValidator
\r
2 def validate_each(record, attribute, value)
\r
3 record.picture.boosts 'post'
\r
4 if record.picture and record.picture.license_extend.sync_vh < 0
\r
5 record.errors[attribute] << (options[:message] || I18n.t('activerecord.errors.messages.sync_vh')) unless sync?(record)
\r
10 r = record.width * 100 / record.height
\r
11 r2 = record.picture.width * 100 / record.picture.height
\r
12 (r >= r2 - 1) and (r <= r2 + 1)
\r