Class: Logistics::Core::UnitTypesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/logistics/core/unit_types_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/logistics/core/unit_types_controller.rb', line 12

def create
  @unit_type = UnitType.new(unit_type_params)
  if @unit_type.save
    response = Mks::Common::MethodResponse.new(true, 'Unit type saved successfully!', @unit_type, nil, nil)
  else
    errors = Mks::Common::Util.error_messages @unit_type, 'Unit type'
    response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil)
  end
  render json: response
end

#indexObject



6
7
8
9
10
# File 'app/controllers/logistics/core/unit_types_controller.rb', line 6

def index
  unit_types = UnitType.all
  response = Mks::Common::MethodResponse.new(true, nil, unit_types, nil, nil)
  render json: response
end

#updateObject



23
24
25
26
27
28
29
30
31
# File 'app/controllers/logistics/core/unit_types_controller.rb', line 23

def update
  if @unit_type.update(unit_type_params)
    response = Mks::Common::MethodResponse.new(true, "Unit type updated successfully!", @unit_type, nil, nil)
  else
    errors = Mks::Common::Util.error_messages @unit_type, "Unit type"
    response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil)
  end
  render json: response
end