Sha256: eadc42a3c1a01a437b7db1c75114fa7ea2d9ec3978b330dce5d070bdecbb8353
Contents?: true
Size: 1.55 KB
Versions: 28
Compression:
Stored size: 1.55 KB
Contents
require_dependency "renalware/hospitals" module Renalware module Hospitals class UnitsController < BaseController before_action :load_hospital_unit, only: [:edit, :update] def new @hospital_unit = Unit.new authorize @hospital_unit end def create @hospital_unit = Unit.new(hospital_unit_params) authorize @hospital_unit if @hospital_unit.save redirect_to hospitals_units_path, notice: t(".success", model_name: "hospital unit") else flash.now[:error] = t(".failed", model_name: "hospital unit") render :new end end def index @hospital_units = Unit.all authorize @hospital_units end def update if @hospital_unit.update(hospital_unit_params) redirect_to hospitals_units_path, notice: t(".success", model_name: "hospital unit") else flash.now[:error] = t(".failed", model_name: "hospital unit") render :edit end end def destroy authorize Unit.destroy(params[:id]) redirect_to hospitals_units_path, notice: t(".success", model_name: "hospital unit") end private def hospital_unit_params params.require(:hospitals_unit).permit( :name, :unit_code, :renal_registry_code, :unit_type, :hospital_centre_id, :is_hd_site ) end def load_hospital_unit @hospital_unit = Unit.find(params[:id]) authorize @hospital_unit end end end end
Version data entries
28 entries across 28 versions & 1 rubygems