Class: Grime::ApiController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/grime/api_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
# File 'app/controllers/grime/api_controller.rb', line 16

def create
  ActiveRecord::Base.transaction do
    @object = scope.create
    @object.update_attributes!(params[params_key])
  end
  render json: @object
end

#destroyObject



29
30
31
# File 'app/controllers/grime/api_controller.rb', line 29

def destroy
  render json: @object.destroy!
end

#indexObject



8
9
10
# File 'app/controllers/grime/api_controller.rb', line 8

def index
  render json: scope.all
end

#showObject



12
13
14
# File 'app/controllers/grime/api_controller.rb', line 12

def show
  render json: @object
end

#updateObject



24
25
26
27
# File 'app/controllers/grime/api_controller.rb', line 24

def update
  @object.update!(params[params_key])
  render json: @object
end