Sha256: 6d3a06c25edaaa389d7c681937246fa0b60c627d4a604f8b90beac6a87d7c287

Contents?: true

Size: 656 Bytes

Versions: 7

Compression:

Stored size: 656 Bytes

Contents

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  has_many :project_assignments
  
  class << self
    def current_user=(user)
      Thread.current[:current_user] = user
    end

    def current_user
      Thread.current[:current_user]
    end

    def current(user)
      orig_user, User.current_user = User.current_user, user
      begin
        return yield
      ensure
        User.current_user = orig_user
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
model_base_generators-0.3.2 example/app/models/user.rb
model_base_generators-0.3.1 example/app/models/user.rb
model_base_generators-0.3.0 example/app/models/user.rb
model_base_generators-0.2.4 example/app/models/user.rb
model_base_generators-0.2.3 example/app/models/user.rb
model_base_generators-0.2.2 example/app/models/user.rb
model_base_generators-0.2.1 example/app/models/user.rb