Class: UsersController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#after_sign_in_path_for, #api_authenticate!, #current_project, #expire_revision!, #followed_projects, #no_cache, #read_revision, #require_login, #return_or_cache_revision!, #revision, #save_current_project, #set_current_project, #unfurling?

Methods included from UrlHelper

#edit_release_path, #edit_release_url, #feature_path, #github_commit_range_url, #github_commit_url, #github_project_url, #github_url?, #goldmine_case_number_url, #link_to_project_feature, #new_release_url, #release_path, #release_url, #releases_path

Instance Method Details

#createObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/users_controller.rb', line 40

def create
  @user = User.new(user_params)

  if params[:send_invitation]
    User.invite!(params[:user])
  else
    @user.administrator = @administrator
    @user.skip_password = true
    @user.save!
  end

  redirect_to @user, notice: 'User was successfully invited.'

rescue ActiveRecord::RecordInvalid
  flash.now[:error] = @user.errors[:base].join("\n")
  render action: "new"
end

#destroyObject



76
77
78
79
80
81
# File 'app/controllers/users_controller.rb', line 76

def destroy
  @user = User.find(params[:id])
  @user.retire!

  redirect_to users_url
end

#editObject



28
29
30
# File 'app/controllers/users_controller.rb', line 28

def edit
  @user = User.find(params[:id])
end

#indexObject



6
7
8
9
10
11
12
13
# File 'app/controllers/users_controller.rb', line 6

def index
  @title = "Team"
  @users = User.unretired

  @ticket_stats_by_user = @users.each_with_object({}) do |user, stats|
    stats[user] = stats_for_user(user)
  end
end

#inviteObject



33
34
35
36
37
# File 'app/controllers/users_controller.rb', line 33

def invite
  @user = User.find(params[:id])
  @user.invite!
  redirect_to request.referrer, :notice => "#{@user.name} has been invited to use this program"
end

#newObject



23
24
25
# File 'app/controllers/users_controller.rb', line 23

def new
  @user = User.new
end

#showObject



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

def show
  @user = User.find(params[:id])
  @title = @user.name
  @stats = stats_for_user(@user)
end

#updateObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/users_controller.rb', line 59

def update
  @user = User.find(params[:id])
  @user.administrator = @administrator

  attributes = params[:user]
  attributes[:alias_emails] = attributes.fetch(:alias_emails, "").split.map(&:strip)
  attributes[:view_options] = @user.view_options.merge(attributes[:view_options] || {})

  if @user.update_attributes(attributes)
    redirect_to @user, notice: 'User was successfully updated.'
  else
    flash.now[:error] = @user.errors[:base].join("\n")
    render action: "edit"
  end
end