Class: MotoWebEngine::ApiRunsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- MotoWebEngine::ApiRunsController
- Defined in:
- app/controllers/moto_web_engine/api_runs_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#index ⇒ Object
skip_before_action :verify_authenticity_token.
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
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 |
#index ⇒ Object
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 |
#show ⇒ Object
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 |
#update ⇒ Object
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 |