Class: Renalware::HD::StationsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- ApplicationController
- BaseController
- BaseController
- Renalware::HD::StationsController
- Includes:
- PresenterHelper
- Defined in:
- app/controllers/renalware/hd/stations_controller.rb
Instance Method Summary collapse
Methods included from PresenterHelper
Methods inherited from BaseController
Instance Method Details
#create ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/renalware/hd/stations_controller.rb', line 27 def create station = Station.new(station_params.merge!(hospital_unit_id: unit_id)) 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 |
#edit ⇒ Object
37 38 39 40 |
# File 'app/controllers/renalware/hd/stations_controller.rb', line 37 def edit station render_edit(station) end |
#index ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/controllers/renalware/hd/stations_controller.rb', line 11 def index stations = Station.for_unit(unit_id).ordered stations render locals: { unit_id: unit_id, stations: present(stations, StationPresenter) } end |
#new ⇒ Object
20 21 22 23 24 25 |
# File 'app/controllers/renalware/hd/stations_controller.rb', line 20 def new station = Station.new(hospital_unit_id: unit_id) station.by = current_user station render_new(station) end |
#sort ⇒ Object
51 52 53 54 55 56 |
# File 'app/controllers/renalware/hd/stations_controller.rb', line 51 def sort Station, :sort? ids = params["hd-station"] Station.sort(ids) render json: ids end |
#update ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'app/controllers/renalware/hd/stations_controller.rb', line 42 def update 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 |