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