Class: Papercat::Api::BaseController

Inherits:
Papercat::ApplicationController show all
Defined in:
app/controllers/papercat/api/base_controller.rb

Instance Method Summary collapse

Methods inherited from Papercat::ApplicationController

#admin

Instance Method Details

#createObject



24
25
26
27
28
# File 'app/controllers/papercat/api/base_controller.rb', line 24

def create
  @record = model.new(model_params)
  @record.save
  respond_with(@record, location: record_path)
end

#destroyObject



35
36
37
38
# File 'app/controllers/papercat/api/base_controller.rb', line 35

def destroy
  @record.destroy
  respond_with(@record, location: collection_path)
end

#indexObject



16
17
18
# File 'app/controllers/papercat/api/base_controller.rb', line 16

def index
  respond_with(@collection, location: collection_path)
end

#showObject



20
21
22
# File 'app/controllers/papercat/api/base_controller.rb', line 20

def show
  respond_with(@record, location: record_path)
end

#updateObject



30
31
32
33
# File 'app/controllers/papercat/api/base_controller.rb', line 30

def update
  @record.update(model_params)
  respond_with(@record, location: record_path)
end