Class: ModelInfo::Api::V1::ModelsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/model_info/api/v1/models_controller.rb

Overview

:nodoc

Instance Method Summary collapse

Methods inherited from BaseController

#models_array

Instance Method Details

#createObject



18
19
20
21
22
23
# File 'app/controllers/model_info/api/v1/models_controller.rb', line 18

def create
  model_object = model.new(permit_params)
  if model_object.save
    render json: { status: :created }
  end
end

#destroyObject



29
30
31
# File 'app/controllers/model_info/api/v1/models_controller.rb', line 29

def destroy
  @model_object.destroy
end

#indexObject

GET /models or /models.json



9
10
11
# File 'app/controllers/model_info/api/v1/models_controller.rb', line 9

def index
  render json: model.all
end

#showObject

GET /comapnies/new



14
15
16
# File 'app/controllers/model_info/api/v1/models_controller.rb', line 14

def show
  render json: @model_object
end

#updateObject



25
26
27
# File 'app/controllers/model_info/api/v1/models_controller.rb', line 25

def update
  @model_object.update(permit_params)
end