Add create expert method

This commit is contained in:
kara Diaby 2021-01-15 16:33:36 +01:00
parent e0cb0eebab
commit da067597ab
2 changed files with 65 additions and 0 deletions

View file

@ -130,6 +130,20 @@ class User < ApplicationRecord
user
end
def self.create_or_promote_to_expert(email, password)
user = User
.create_with(password: password, confirmed_at: Time.zone.now)
.find_or_create_by(email: email)
if user.valid?
if user.expert_id.nil?
user.create_expert!
end
end
user
end
def flipper_id
"User:#{id}"
end