Sha256: 9a21f08b534d509a22d13b42071a65c7648dbeb4eefb78f77cb53d7da247d0bf

Contents?: true

Size: 1.08 KB

Versions: 25

Compression:

Stored size: 1.08 KB

Contents

module Workarea
  module Admin
    class CreateReleaseUndosController < Admin::ApplicationController
      required_permissions :releases

      before_action :find_release
      before_action :find_undo_release

      def new
      end

      def create
        @undo_release.attributes = params[:release]

        if @undo_release.save
          @release.changesets.each do |changeset|
            changeset.build_undo(release: @undo_release.model).save!
          end

          flash[:success] = t('workarea.admin.create_release_undos.flash_messages.saved')
          redirect_to review_release_undo_path(@release)
        else
          render :new, status: :unprocessable_entity
        end
      end

      def review
      end

      private

      def find_release
        model = Release.find(params[:release_id])
        @release = ReleaseViewModel.new(model, view_model_options)
      end

      def find_undo_release
        model = @release.model.undo || @release.build_undo(params[:release])
        @undo_release = ReleaseViewModel.new(model, view_model_options)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
workarea-admin-3.5.3 app/controllers/workarea/admin/create_release_undos_controller.rb
workarea-admin-3.5.2 app/controllers/workarea/admin/create_release_undos_controller.rb
workarea-admin-3.5.1 app/controllers/workarea/admin/create_release_undos_controller.rb
workarea-admin-3.5.0 app/controllers/workarea/admin/create_release_undos_controller.rb
workarea-admin-3.5.0.beta.1 app/controllers/workarea/admin/create_release_undos_controller.rb