Sha256: 70804552c58575715e794c2d90fed8dd72e639e8ad175806ce9f6312397469be

Contents?: true

Size: 543 Bytes

Versions: 2

Compression:

Stored size: 543 Bytes

Contents

module Arcadex
  class Token < ActiveRecord::Base
    include IdentityCache
    cache_index :auth_token, :unique => true

  	before_validation :generate_hash, on: :create

		belongs_to :imageable, :polymorphic => true

    validates :imageable_id, presence: true
    validates :imageable_type, presence: true
    validates :auth_token, presence: true
    #This also happens at the database level
    validates :auth_token, uniqueness: true

    def generate_hash
    	self.auth_token = ::Arcadex::Create.generate_auth_token
    end	
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arcadex-1.3.1 app/models/arcadex/token.rb
arcadex-1.3.0 app/models/arcadex/token.rb