Sha256: a4963e2ad3b2851d0048acd03bb524d1f4020bafc34f348ed17992c230233f03
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
class BooksController < ApplicationController # GET /books # GET /books.json def index @books = Book.all respond_to do |format| format.html # index.html.erb format.json { render json: @books } end end # GET /books/1 # GET /books/1.json def show @book = Book.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @book } end end # GET /books/new # GET /books/new.json def new @book = Book.new respond_to do |format| format.html # new.html.erb format.json { render json: @book } end end # GET /books/1/edit def edit @book = Book.find(params[:id]) end # POST /books # POST /books.json def create @book = Book.new(params[:book]) respond_to do |format| if @book.save format.html { redirect_to @book, notice: 'Book was successfully created.' } format.json { render json: @book, status: :created, location: @book } else format.html { render action: "new" } format.json { render json: @book.errors, status: :unprocessable_entity } end end end # PUT /books/1 # PUT /books/1.json def update @book = Book.find(params[:id]) respond_to do |format| if @book.update_attributes(params[:book]) format.html { redirect_to @book, notice: 'Book was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @book.errors, status: :unprocessable_entity } end end end # DELETE /books/1 # DELETE /books/1.json def destroy @book = Book.find(params[:id]) @book.destroy respond_to do |format| format.html { redirect_to books_url } format.json { head :no_content } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nice-0.0.2 | test/nizzaTestApp/app/controllers/books_controller.rb |