AutoCommit Mon Jun 8 22:03:14 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-06-08 22:03:14 +02:00
parent 18021fb502
commit cc2ab28d16
11 changed files with 83 additions and 9 deletions

11
app/models/key.rb Normal file
View 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