Class: UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/users_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#stored_location_for

Instance Method Details

#createObject


16
17
18
19
20
21
22
23
# File 'app/controllers/users_controller.rb', line 16

def create
  if user.save
    flash[:success] = "#{user.name} is now part of the team. Be sure to add them as a project watcher."
    redirect_to user_path(user)
  else
    render :new
  end
end

#destroyObject

Destroy the user pass in args

Parameters:

  • id (String)

    the id of user we want delete


39
40
41
42
43
44
45
46
47
# File 'app/controllers/users_controller.rb', line 39

def destroy
  if user == current_user
    flash[:error] = I18n.t('controllers.users.flash.destroy.error')
  else
    UserDestroy.new(user).destroy
    flash[:success] = I18n.t('controllers.users.flash.destroy.success', :name => user.name)
  end
  redirect_to users_path
end

#indexObject


12
# File 'app/controllers/users_controller.rb', line 12

def index; end

#newObject


13
# File 'app/controllers/users_controller.rb', line 13

def new; end

#showObject


14
# File 'app/controllers/users_controller.rb', line 14

def show; end

49
50
51
52
# File 'app/controllers/users_controller.rb', line 49

def unlink_github
  user.update_attributes :github_login => nil, :github_oauth_token => nil
  redirect_to user_path(user)
end

#updateObject


25
26
27
28
29
30
31
32
# File 'app/controllers/users_controller.rb', line 25

def update
  if user.update_attributes(user_params)
    flash[:success] = I18n.t('controllers.users.flash.update.success', :name => user.name)
    redirect_to user_path(user)
  else
    render :edit
  end
end