Class: UsersController
Instance Method Summary
collapse
included
#current_ability
#parent, #voluntary_application_javascripts, #voluntary_application_stylesheets
included
Instance Method Details
#destroy ⇒ Object
42
43
44
45
46
47
|
# File 'app/controllers/users_controller.rb', line 42
def destroy
raise CanCan::AccessDenied if !current_user || (current_user.id != @user.id && !current_user.roles?(:master))
@user.destroy
redirect_to users_url, notice: t('general.form.destroyed')
end
|
#edit ⇒ Object
20
21
22
|
# File 'app/controllers/users_controller.rb', line 20
def edit
@user.attributes = params[:user] if params[:user].present?
end
|
#index ⇒ Object
8
9
10
11
|
# File 'app/controllers/users_controller.rb', line 8
def index
parent = find_parent User::PARENT_TYPES
@users = parent ? parent.users : User.all
end
|
#languages ⇒ Object
13
14
15
|
# File 'app/controllers/users_controller.rb', line 13
def languages
render json: User.languages(params[:q]).to_json and return
end
|
#preferences ⇒ Object
24
25
26
27
28
29
30
|
# File 'app/controllers/users_controller.rb', line 24
def preferences
raise CanCan::AccessDenied if !current_user || (current_user.id != @user.id && !current_user.roles?(:master))
if params[:user] && @user.update_attributes(params[:user])
redirect_to preferences_user_path(@user), notice: t('general.form.successfully_updated') and return
end
end
|
#resource ⇒ Object
49
50
51
|
# File 'app/controllers/users_controller.rb', line 49
def resource
@user
end
|
#show ⇒ Object
17
18
|
# File 'app/controllers/users_controller.rb', line 17
def show
end
|
#update ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/users_controller.rb', line 32
def update
raise CanCan::AccessDenied if !current_user || (current_user.id != @user.id && !current_user.roles?(:master))
if @user.update_attributes(params[:user])
redirect_to edit_user_path(@user), notice: t('general.form.successfully_updated')
else
render :edit
end
end
|