Class: Renalware::Hospitals::WardsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- ApplicationController
- BaseController
- Renalware::Hospitals::WardsController
- Defined in:
- app/controllers/renalware/hospitals/wards_controller.rb
Instance Method Summary collapse
Methods inherited from BaseController
Instance Method Details
#create ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/renalware/hospitals/wards_controller.rb', line 27 def create ward = unit.wards.build(ward_params) ward if ward.save redirect_to hospitals_unit_wards_path(unit), notice: success_msg_for(:ward) else render_new(ward) end end |
#destroy ⇒ Object
50 51 52 53 |
# File 'app/controllers/renalware/hospitals/wards_controller.rb', line 50 def destroy .destroy! redirect_to hospitals_unit_wards_path(unit), notice: success_msg_for(:ward) end |
#edit ⇒ Object
37 38 39 |
# File 'app/controllers/renalware/hospitals/wards_controller.rb', line 37 def edit render_edit() end |
#index ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/renalware/hospitals/wards_controller.rb', line 8 def index Ward, :index? wards = Ward.where(hospital_unit_id: unit.id).order(name: :asc) respond_to do |format| format.json do render json: wards.select(:id, :name).to_json end format.html do render locals: { unit: unit, wards: wards } end end end |
#new ⇒ Object
21 22 23 24 25 |
# File 'app/controllers/renalware/hospitals/wards_controller.rb', line 21 def new ward = unit.wards.build ward render_new(ward) end |
#update ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'app/controllers/renalware/hospitals/wards_controller.rb', line 41 def update ward = if ward.update(ward_params) redirect_to hospitals_unit_wards_path(unit), notice: success_msg_for(:ward) else render_edit() end end |