Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This class is responsible for the Books REST interface.
- #
- class BooksController < ApplicationController
- # Get a book by the id
- before_filter :get_book, only: [:edit, :update, :show, :destroy]
- # Renders the form to create a new Book.
- #
- def new
- @book = Book.new
- end
- # Creates a new Book from the params and redirects to edit view.
- #
- def create
- @book = Book.create(params[:book])
- redirect_to book_path(@book)
- end
- # Renders the form for a given book.
- #
- def edit
- end
- # Updates a Book from the params and redirects to edit view.
- #
- def update
- @book.update(params[:book])
- redirect_to edit_book_path(@book)
- end
- # Renders all books
- #
- def index
- @books = Book.all
- end
- # Renders a Book with its clips
- #
- def show
- end
- # Destroys the Book object from database
- #
- def destroy
- @book.destroy
- redirect_to action: :index
- end
- private
- def get_book
- @book = Book.get(params[:id])
- end
- end
Add Comment
Please, Sign In to add comment