Class: Logistics::Core::ContentTypesController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /content_types POST /content_types.json



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

def create
  @content_type = ContentType.new(content_type_params)
  if @content_type.valid?
    if @content_type.save
      response = Mks::Common::MethodResponse.new(true, "Content Type data Saved Successfully!", @content_type, nil, nil)
    end
  else
    errors = Mks::Common::Util.error_messages @content_type
    response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil)
  end
  render json: response
end

#indexObject

GET /content_types GET /content_types.json



8
9
10
11
12
# File 'app/controllers/logistics/core/content_types_controller.rb', line 8

def index
  @content_types = ContentType.all
  response = Mks::Common::MethodResponse.new(true, nil, @content_types, nil, nil)
  render json: response
end

#lookupObject



14
15
16
17
18
# File 'app/controllers/logistics/core/content_types_controller.rb', line 14

def lookup
  @content_types = ContentType.order(:name).select("id, name")
  response =Mks::Common::MethodResponse.new(true, nil, @content_types, nil, nil)
  render json: response
end

#updateObject

PATCH/PUT /content_types/1 PATCH/PUT /content_types/1.json



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/logistics/core/content_types_controller.rb', line 37

def update
  @old_content_type = set_content_type
  @content_type = ContentType.new(content_type_params)
  if @content_type.valid?
    if @old_content_type.update(content_type_params)
      response = Mks::Common::MethodResponse.new(true, "Content Type data Updated Successfully!", nil, nil)
    end
  else
    errors = Mks::Common::Util.error_messages @content_type
    response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil)
  end
  render json: response
end