Class: UsersController
Instance Method Summary
collapse
#after_sign_in_path_for, #api_authenticate!, #authenticated_via_token?, #current_project, #expire_revision!, #followed_projects, #no_cache, #oauth_authorize!, #read_revision, #require_login, #return_or_cache_revision!, #revision, #token_authenticate!, #unfurling?, #with_current_project
Methods included from UrlHelper
#feature_path, #link_to_project_feature
Instance Method Details
#create ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/users_controller.rb', line 35
def create
@user = User.new(user_params)
if params[:send_invitation]
User.invite!(params[:user])
else
@user.role = @role
@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
|
#destroy ⇒ Object
70
71
72
73
74
75
|
# File 'app/controllers/users_controller.rb', line 70
def destroy
@user = User.find(params[:id])
@user.retire!
redirect_to users_url
end
|
#edit ⇒ Object
23
24
25
|
# File 'app/controllers/users_controller.rb', line 23
def edit
@user = User.find(params[:id])
end
|
#index ⇒ Object
6
7
8
9
|
# File 'app/controllers/users_controller.rb', line 6
def index
@title = "Users"
@users = User.unretired
end
|
#invite ⇒ Object
28
29
30
31
32
|
# File 'app/controllers/users_controller.rb', line 28
def invite
@user = User.find(params[:id])
@user.invite!
redirect_to request.referrer, :notice => "#{@user.name} has been invited to use this program"
end
|
#new ⇒ Object
18
19
20
|
# File 'app/controllers/users_controller.rb', line 18
def new
@user = User.new
end
|
#show ⇒ Object
12
13
14
15
|
# File 'app/controllers/users_controller.rb', line 12
def show
@user = User.find(params[:id])
@title = @user.name
end
|
#update ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'app/controllers/users_controller.rb', line 53
def update
@user = User.find(params[:id])
@user.role = @role
attributes = params[:user]
attributes[:alias_emails] = attributes.fetch(:alias_emails, "").split.map(&:strip)
@user.props.merge! attributes.delete(:props) if attributes.key?(:props)
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
|