Class: User

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_user(params) ⇒ Object



18
19
20
# File 'app/models/user.rb', line 18

def create_user(params)
  create :email => params[:email], :name => params[:name], :password => params[:password], :password_confirmation => params[:confirm_password]
end

.delete_user(params) ⇒ Object



22
23
24
# File 'app/models/user.rb', line 22

def delete_user(params)
  User.find(params[:id].to_i).destroy
end

.from_auth(auth) ⇒ Object



40
41
42
# File 'app/models/user.rb', line 40

def from_auth(auth)
  where(:provider => auth.provider, :uid => auth.uid).first
end

.update_user(params) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/user.rb', line 26

def update_user(params)
  user = find params[:id].to_i
  user.email = params[:email]
  user.name = params[:name]

  if params[:password].present? || params[:confirm_password].present?
    user.password = params[:password]
    user.password_confirmation = params[:confirm_password]
  end

  user.save!
  user
end

Instance Method Details

#save_auth!(auth) ⇒ Object



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

def save_auth!(auth)
  self.provider = auth.provider
  self.uid = auth.uid
  save!
end

#zip_titleObject



7
8
9
# File 'app/models/user.rb', line 7

def zip_title
  name
end