Class: User

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

Instance Method Summary collapse

Instance Method Details

#is_admin?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'app/models/user.rb', line 11

def is_admin?
  self.is_admin==1 ? true : false
end

#password_required?Boolean

MonkeyPatch of Devise method in devise/lib/devise/models/validatable.rb to enable updating user without specifying password

Returns:

  • (Boolean)


27
28
29
# File 'app/models/user.rb', line 27

def password_required?
  !persisted?  || !password.blank? # || !password_confirmation.nil?
end

#update_with_admin_check(user_params, is_admin = false) ⇒ Object



16
17
18
19
20
21
22
# File 'app/models/user.rb', line 16

def update_with_admin_check(user_params, is_admin=false)
  if is_admin
    self.update_attributes(user_params)
  else
    self.update_with_password(user_params)
  end
end