Class: PaidUp::Validators::RolifyRows

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
lib/paid_up/validators/rolify_rows.rb

Overview

RolifyRows Validator

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/paid_up/validators/rolify_rows.rb', line 5

def validate(record)
  if record.send(options[:field]) == options[:comparison] &&
     !ActiveRecord::Base.connection.table_exists?(
       record.send(options[:found_in])
     )
    record.errors[
      options[:found_in]
    ] << :when_using_rolify_rows_table_must_exist.l
  end
end