Sha256: 1a6add6322fa885d525525675c2db9bda2f237f20016a1a6a686e87720cdd0f6

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

require_dependency "renalware/modalities"

module Renalware
  module Modalities
    class DescriptionsController < BaseController

      before_action :load_modality_description, only: [:edit, :update]

      def new
        @modality_description = Description.new
        authorize @modality_description
      end

      def create
        @modality_description = Description.new(modality_description_params)
        authorize @modality_description

        if @modality_description.save
          redirect_to modalities_descriptions_path,
            notice: t(".success", model_name: "modality description")
        else
          flash[:error] = t(".failed", model_name: "modality description")
          render :new
        end
      end

      def index
        @modalilty_descriptions = Description.all
        authorize @modalilty_descriptions
      end

      def update
        if @modality_description.update(modality_description_params)
          redirect_to modalities_descriptions_path,
            notice: t(".success", model_name: "modality description")
        else
          flash[:error] = t(".failed", model_name: "modality description")
          render :edit
        end
      end

      def destroy
        authorize Description.destroy(params[:id])
        redirect_to modalities_descriptions_path,
          notice: t(".success", model_name: "modality description")
      end

      private

      def modality_description_params
        params.require(:modalities_description).permit(:name, :code, :site)
      end

      def load_modality_description
        @modality_description = Description.find(params[:id])
        authorize @modality_description
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta4 app/controllers/renalware/modalities/descriptions_controller.rb