Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BooksController < ApplicationController
- # GET /books.json
- def index
- books = Book.all
- render :json => books
- end
- # GET /books/7.json
- def show
- book = Book.find(params[:id])
- render :json => book
- end
- # POST /books
- def create
- book = Book.new(params[:book])
- if book.save
- render :status => 200
- else
- render what ever validation error or message you want
- end
- end
- # PUT /books/7
- def update
- book = Book.find(params[:id])
- book.update_attributes(params[:book])
- if book.save
- ....
- end
- end
Add Comment
Please, Sign In to add comment