Class: Logistics::Core::ContentTypesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Logistics::Core::ContentTypesController
- Defined in:
- app/controllers/logistics/core/content_types_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /content_types POST /content_types.json.
-
#index ⇒ Object
GET /content_types GET /content_types.json.
- #lookup ⇒ Object
-
#update ⇒ Object
PATCH/PUT /content_types/1 PATCH/PUT /content_types/1.json.
Instance Method Details
#create ⇒ Object
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. @content_type response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end |
#index ⇒ Object
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 |
#lookup ⇒ Object
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 |
#update ⇒ Object
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. @content_type response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end |