Created
March 31, 2014 21:23
-
-
Save glesage/9902677 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DataController < ApplicationController | |
# GET /data | |
# GET /data.json | |
def index | |
@data = Datum.all | |
render json: @data | |
end | |
# GET /data/1 | |
# GET /data/1.json | |
def show | |
@datum = Datum.find(params[:id]) | |
render json: @datum | |
end | |
# POST /data | |
# POST /data.json | |
def create | |
@datum = Datum.new(params[:datum]) | |
if @datum.save | |
render json: @datum, status: :created, location: @datum | |
else | |
render json: @datum.errors, status: :unprocessable_entity | |
end | |
end | |
# PATCH/PUT /data/1 | |
# PATCH/PUT /data/1.json | |
def update | |
@datum = Datum.find(params[:id]) | |
if @datum.update(params[:datum]) | |
head :no_content | |
else | |
render json: @datum.errors, status: :unprocessable_entity | |
end | |
end | |
# DELETE /data/1 | |
# DELETE /data/1.json | |
def destroy | |
@datum = Datum.find(params[:id]) | |
@datum.destroy | |
head :no_content | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment