Class: Admin::UsersController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Admin::UsersController
- Defined in:
- app/controllers/admin/users_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/admin/users_controller.rb', line 15 def create user = User.new(user_params) if user.save flash[:notice] = 'User was created.' redirect_to admin_users_path else flash[:error] = 'There was an error saving the user. Please try again.' render :new end end |
#ensure_deletable ⇒ Object
41 42 43 44 45 46 |
# File 'app/controllers/admin/users_controller.rb', line 41 def ensure_deletable if current_user.id.to_s == params[:id].to_s announce_cannot_delete_self redirect_to admin_users_path end end |
#show ⇒ Object
11 12 13 |
# File 'app/controllers/admin/users_controller.rb', line 11 def show redirect_to edit_admin_user_path(params[:id]) end |
#update ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/admin/users_controller.rb', line 26 def update user_params = params[model_symbol].permit! if user_params && user_params['admin'] == false && model == current_user user_params.delete('admin') announce_cannot_remove_self_from_admin_role end model.skip_password_validation = true unless user_params[:password_confirmation].present? if model.update(user_params) response_for :update else flash[:error] = 'There was an error saving the user. Please try again.' render :edit end end |