Sha256: 85c6ff57bf1b56e4288aa32b8edb73616e38e082e746c45dc6b6e549561df267
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
class BeersController < ApplicationController # GET /beers # GET /beers.json def index @beers = Beer.all respond_to do |format| format.html # index.html.erb format.json { render json: @beers } end end # GET /beers/1 # GET /beers/1.json def show @beer = Beer.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @beer } end end # GET /beers/new # GET /beers/new.json def new @beer = Beer.new respond_to do |format| format.html # new.html.erb format.json { render json: @beer } end end # GET /beers/1/edit def edit @beer = Beer.find(params[:id]) end # POST /beers # POST /beers.json def create @beer = Beer.new(params[:beer]) respond_to do |format| if @beer.save format.html { redirect_to @beer, notice: 'Beer was successfully created.' } format.json { render json: @beer, status: :created, location: @beer } else format.html { render action: "new" } format.json { render json: @beer.errors, status: :unprocessable_entity } end end end # PUT /beers/1 # PUT /beers/1.json def update @beer = Beer.find(params[:id]) respond_to do |format| if @beer.update_attributes(params[:beer]) format.html { redirect_to @beer, notice: 'Beer was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @beer.errors, status: :unprocessable_entity } end end end # DELETE /beers/1 # DELETE /beers/1.json def destroy @beer = Beer.find(params[:id]) @beer.destroy respond_to do |format| format.html { redirect_to beers_url } format.json { head :ok } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
routespec-0.0.1 | test/rails311/app/controllers/beers_controller.rb |