Sha256: a9068680661b7c877cace35331de49357eb5d8d3da87f167f0f091227ab5e39f
Contents?: true
Size: 1.84 KB
Versions: 29
Compression:
Stored size: 1.84 KB
Contents
require_dependency "renalware/hd/base_controller" require "collection_presenter" module Renalware module HD class StationsController < BaseController include PresenterHelper def index stations = Station.for_unit(unit_id).ordered authorize stations render locals: { unit_id: unit_id, stations: present(stations, StationPresenter) } end def new station = Station.new(hospital_unit_id: unit_id) station.by = current_user authorize station render_new(station) end def create station = Station.new(station_params.merge!(hospital_unit_id: unit_id)) authorize station if station.save_by(current_user) redirect_to hd_unit_stations_path(unit_id: unit_id), notice: success_msg_for("station") else render_new(station) end end def edit authorize station render_edit(station) end def update authorize station if station.update_by(current_user, station_params) redirect_to hd_unit_stations_path(unit_id: unit_id), notice: success_msg_for("station") else render_edit(station) end end def sort authorize Station, :sort? ids = params["hd-station"] Station.sort(ids) render json: ids end private def render_new(station) render :new, locals: { unit_id: unit_id, station: station } end def render_edit(station) render :edit, locals: { unit_id: unit_id, station: station } end def unit_id params[:unit_id] end def station @station ||= Station.find(params[:id]) end def station_params params.require(:hd_station).permit(:name, :location_id) end end end end
Version data entries
29 entries across 29 versions & 1 rubygems