Merge branch 'develop' into feature/rspec-tests
This commit is contained in:
commit
229b7d2cc5
1 changed files with 3 additions and 8 deletions
|
@ -7,7 +7,7 @@ class User < ActiveRecord::Base
|
||||||
has_many :maps
|
has_many :maps
|
||||||
has_many :mappings
|
has_many :mappings
|
||||||
|
|
||||||
before_create :generate_code
|
after_create :generate_code
|
||||||
|
|
||||||
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable
|
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable
|
||||||
|
|
||||||
|
@ -66,15 +66,10 @@ class User < ActiveRecord::Base
|
||||||
def generate_code
|
def generate_code
|
||||||
self.code = rand(36**8).to_s(36)
|
self.code = rand(36**8).to_s(36)
|
||||||
$codes.push(self.code)
|
$codes.push(self.code)
|
||||||
self.generation = self.get_generation
|
self.generation = get_generation!
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_generation
|
def get_generation!
|
||||||
calculate_generation() if generation.nil?
|
|
||||||
generation
|
|
||||||
end
|
|
||||||
|
|
||||||
def calculate_generation
|
|
||||||
if code == joinedwithcode
|
if code == joinedwithcode
|
||||||
update(generation: 0)
|
update(generation: 0)
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue