Class: User

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
BCrypt
Defined in:
lib/ecrire/app/models/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#password_confirmationObject

Returns the value of attribute password_confirmation.



6
7
8
# File 'lib/ecrire/app/models/user.rb', line 6

def password_confirmation
  @password_confirmation
end

Instance Method Details

#passwordObject



16
17
18
19
# File 'lib/ecrire/app/models/user.rb', line 16

def password
  return if self.encrypted_password.blank?
  @password ||= Password.new(self.encrypted_password)
end

#password=(new_password) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/ecrire/app/models/user.rb', line 21

def password=(new_password)
  if new_password.nil?
    self.encrypted_password = nil
  elsif new_password.present?
    @password = Password.create(new_password)
    self.encrypted_password = @password
  end
end