Class: MotoWebEngine::ApiRunsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/moto_web_engine/api_runs_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
20
21
# File 'app/controllers/moto_web_engine/api_runs_controller.rb', line 15

def create
  input = JSON.parse(request.body.read)
  # validate input hash here (or delegate to some private method)
  run = Run.new input
  run.save!
  render json: run
end

#indexObject

skip_before_action :verify_authenticity_token



8
9
10
11
12
13
# File 'app/controllers/moto_web_engine/api_runs_controller.rb', line 8

def index
  offset = params[:offset] || 0
  limit = params[:limit] || 20
  @runs = Run.order('id DESC').offset(offset).limit(limit)
  render json: @runs
end

#showObject



32
33
34
35
# File 'app/controllers/moto_web_engine/api_runs_controller.rb', line 32

def show
  run = Run.find params[:id]
  render json: run
end

#updateObject



23
24
25
26
27
28
29
30
# File 'app/controllers/moto_web_engine/api_runs_controller.rb', line 23

def update
  run = Run.find params[:id]
  input = JSON.parse(request.body.read)
  puts input
  # validate input hash here (or delegate to some private method)
  run.update input
  render json: run
end