Class: DataMigration::MigrationStepsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- DataMigration::MigrationStepsController
- Includes:
- PunditAuthorization
- Defined in:
- app/controllers/data_migration/migration_steps_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/data_migration/migration_steps_controller.rb', line 23 def create @migration_step = @migration_plan.migration_steps.new(migration_step_params) @migration_step # Validate JSON fields before saving validation_errors = validate_json_fields(@migration_step) if validation_errors.any? validation_errors.each { |error| @migration_step.errors.add(:base, error) } render :new, status: :unprocessable_entity return end if @migration_step.save redirect_to "/data_migration/migration_plans/#{@migration_plan.id}", notice: 'Migration step was successfully created.' else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
69 70 71 72 73 74 75 |
# File 'app/controllers/data_migration/migration_steps_controller.rb', line 69 def destroy @migration_step @migration_step.destroy redirect_to "/data_migration/migration_plans/#{@migration_plan.id}", notice: 'Migration step was successfully destroyed.' end |
#edit ⇒ Object
43 44 45 |
# File 'app/controllers/data_migration/migration_steps_controller.rb', line 43 def edit @migration_step end |
#index ⇒ Object
10 11 12 |
# File 'app/controllers/data_migration/migration_steps_controller.rb', line 10 def index @migration_steps = policy_scope(MigrationStep).where(migration_plan_id: params[:migration_plan_id]).order(:sequence) end |
#new ⇒ Object
18 19 20 21 |
# File 'app/controllers/data_migration/migration_steps_controller.rb', line 18 def new @migration_step = @migration_plan.migration_steps.new @migration_step end |
#show ⇒ Object
14 15 16 |
# File 'app/controllers/data_migration/migration_steps_controller.rb', line 14 def show @migration_step end |
#update ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/data_migration/migration_steps_controller.rb', line 47 def update @migration_step # Assign attributes first @migration_step.assign_attributes(migration_step_params) # Validate JSON fields before saving validation_errors = validate_json_fields(@migration_step) if validation_errors.any? validation_errors.each { |error| @migration_step.errors.add(:base, error) } render :edit, status: :unprocessable_entity return end if @migration_step.save redirect_to "/data_migration/migration_plans/#{@migration_plan.id}", notice: 'Migration step was successfully updated.' else render :edit, status: :unprocessable_entity end end |