Created
August 25, 2014 23:07
-
-
Save bridgpal/99b5923c948c11190acb 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 BooksController < ApplicationController | |
before_action :set_book, only: [:show, :update, :destroy] | |
respond_to :json | |
def index | |
respond_with Book.all | |
end | |
def create | |
respond_with Book.create(book_params) | |
end | |
def show | |
respond_with @book | |
end | |
def update | |
respond_with @book.update(book_params) | |
end | |
def destroy | |
respond_with @book.destroy | |
end | |
private | |
def set_book | |
@book = Book.find(params[:id]) | |
end | |
def book_params | |
params.require(:book).permit(:title, :author, :description, :isbn) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment