module Jobshop class Site < ApplicationRecord belongs_to :owner, class_name: "Jobshop::User" has_many :users, class_name: "Jobshop::User" def generate_configuration_token raw, encrypted = Devise.token_generator.generate(self.class, :configuration_token) self.configuration_token = encrypted self.configuration_token_sent_at = Time.now.utc self.save(validate: false) raw end def configuration_token_period_valid? configuration_token_sent_at && configuration_token_sent_at.utc >= 30.minutes.ago.utc end end end