Class: DataMigration::UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- DataMigration::UsersController
- Includes:
- PunditAuthorization
- Defined in:
- app/controllers/data_migration/users_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/data_migration/users_controller.rb', line 19 def create DataMigrationUser @user = DataMigrationUser.new(user_params) if @user.save redirect_to '/data_migration/users', notice: 'User created successfully.' else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/data_migration/users_controller.rb', line 51 def destroy @user if @user.destroy redirect_to '/data_migration/users', notice: 'User deleted successfully.' else redirect_to '/data_migration/users', alert: @user.errors..join(', ') end end |
#edit ⇒ Object
30 31 32 |
# File 'app/controllers/data_migration/users_controller.rb', line 30 def edit @user end |
#index ⇒ Object
9 10 11 12 |
# File 'app/controllers/data_migration/users_controller.rb', line 9 def index DataMigrationUser @users = policy_scope(DataMigrationUser).ordered_by_email end |
#new ⇒ Object
14 15 16 17 |
# File 'app/controllers/data_migration/users_controller.rb', line 14 def new DataMigrationUser @user = DataMigrationUser.new end |
#update ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/data_migration/users_controller.rb', line 34 def update @user # Remove password if blank params_to_update = if user_params[:password].blank? user_params.except(:password, :password_confirmation) else user_params end if @user.update(params_to_update) redirect_to '/data_migration/users', notice: 'User updated successfully.' else render :edit, status: :unprocessable_entity end end |