Sha256: 4f85d9e3c341fedf51b91121ebc78471cf4b034c66c72c40e45541f47c583ea5

Contents?: true

Size: 697 Bytes

Versions: 1

Compression:

Stored size: 697 Bytes

Contents

module FinePrint
  class Signature < ActiveRecord::Base
    belongs_to :contract, :inverse_of => :signatures
    belongs_to :user, :polymorphic => true

    validate :contract_published, :on => :create

    validates :contract, :presence => true
    validates :contract_id, :uniqueness => {:scope => [:user_type, :user_id]}
    validates :user, :presence => true

    default_scope { order(:contract_id, :user_type, :user_id) }

    protected

    ##############
    # Validation #
    ##############

    def contract_published
      return if contract.is_published?
      errors.add(:contract, I18n.t(
        'fine_print.signature.errors.contract.not_published'))
      false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fine_print-2.3.1 app/models/fine_print/signature.rb