AutoCommit Mon Jun 8 22:03:14 CEST 2015
This commit is contained in:
11
app/models/key.rb
Normal file
11
app/models/key.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
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
|
||||
Reference in New Issue
Block a user