Sha256: 6ac3890067aefac9690e9c254dd0c596120e61829aabbd5868a1305787bbb86e

Contents?: true

Size: 1.63 KB

Versions: 34

Compression:

Stored size: 1.63 KB

Contents

require_dependency "renalware/events"

module Renalware
  module Events
    class TypesController < BaseController
      def new
        event_type = Type.new
        authorize event_type
        render locals: { event_type: event_type }
      end

      def create
        event_type = Type.new(event_params)
        authorize event_type
        if event_type.save
          redirect_to events_types_path, notice: success_msg_for("event type")
        else
          flash.now[:error] = failed_msg_for("event type")
          render :new, locals: { event_type: event_type }
        end
      end

      def index
        event_types = Type.all
        authorize event_types
        render locals: { event_types: event_types }
      end

      def edit
        event_type = load_and_authorize_event_type
        render locals: { event_type: event_type }
      end

      def update
        event_type = load_and_authorize_event_type
        if event_type.update(event_params)
          redirect_to events_types_path, notice: success_msg_for("event type")
        else
          flash.now[:error] = failed_msg_for("event type")
          render :edit, locals: { event_type: event_type }
        end
      end

      def destroy
        event_type = load_and_authorize_event_type
        event_type.destroy
        redirect_to events_types_path, notice: success_msg_for("event type")
      end

      private

      def event_params
        params.require(:events_type).permit(:name, :deleted_at)
      end

      def load_and_authorize_event_type
        event_type = Type.find(params[:id])
        authorize event_type
        event_type
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
renalware-core-2.0.16 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.15 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.14 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.13 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.12 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.11 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.9 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.8 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.7 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.5 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.4 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.3 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.2 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.1 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.0 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.0.pre.rc13 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.0.pre.rc11 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.0.pre.rc10 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.0.pre.rc9 app/controllers/renalware/events/types_controller.rb
renalware-core-2.0.0.pre.rc8 app/controllers/renalware/events/types_controller.rb