12 lines
368 B
Ruby
12 lines
368 B
Ruby
class Key < ActiveRecord::Base
|
|
attr_accessible :expire, :is_valid, :type, :user_id
|
|
belongs_to :parent, :polymorphic => true
|
|
belongs_to :user
|
|
before_create :create_unique_identifier
|
|
def create_unique_identifier
|
|
begin
|
|
self.uuid = SecureRandom.hex(10) # or whatever you chose like UUID tools
|
|
end while self.class.exists?(:uuid => uuid)
|
|
end
|
|
end
|