Class: Mks::Maintenance::CostTypesController
- Inherits:
-
ApplicationController
- Object
- Auth::ApplicationController
- ApplicationController
- Mks::Maintenance::CostTypesController
- Defined in:
- app/controllers/mks/maintenance/cost_types_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/mks/maintenance/cost_types_controller.rb', line 13 def create params = cost_type_params params[:fields] = JSON(params[:fields]) cost_type = CostType.new(params) if cost_type.save response = Mks::Common::MethodResponse.success_response(cost_type, 'Cost type saved successfully!') render json: response, status: :created, location: cost_type else response = Mks::Common::MethodResponse.failure_response(cost_type) render json: response, status: :unprocessable_entity end end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/mks/maintenance/cost_types_controller.rb', line 5 def index render json: Mks::Common::MethodResponse.success_response(CostType.all) end |
#show ⇒ Object
9 10 11 |
# File 'app/controllers/mks/maintenance/cost_types_controller.rb', line 9 def show render json: Mks::Common::MethodResponse.success_response(@cost_type) end |
#update ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/mks/maintenance/cost_types_controller.rb', line 26 def update params = cost_type_params params[:fields] = JSON(params[:fields]) if params[:fields] if @cost_type.update(params) response = Mks::Common::MethodResponse.success_response(@cost_type, 'Cost type updated successfully!') render json: response else render json: Mks::Common::MethodResponse.failure_response(@cost_type), status: :unprocessable_entity end end |