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



15
16
17
# File 'app/models/user.rb', line 15

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

.delete_user(params) ⇒ Object



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

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

.from_auth(auth) ⇒ Object



37
38
39
# File 'app/models/user.rb', line 37

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

.update_user(params) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/user.rb', line 23

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



8
9
10
11
12
# File 'app/models/user.rb', line 8

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

#zip_titleObject



4
5
6
# File 'app/models/user.rb', line 4

def zip_title
  name
end