Sha256: 6b5bd12ede2fe849bb8baea97168b24e73bc759d0dd08d4e247985fbcc4bf4f2

Contents?: true

Size: 463 Bytes

Versions: 2

Compression:

Stored size: 463 Bytes

Contents

module Arcadex
  class Token < ActiveRecord::Base
  	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.generate_auth_token
    end	
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arcadex-1.0.4 app/models/arcadex/token.rb
arcadex-1.0.3 app/models/arcadex/token.rb