class CrapsController < ApplicationController
# GET /craps
# GET /craps.xml
def index
@craps = Crap.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @craps }
end
end
# GET /craps/1
# GET /craps/1.xml
def show
@crap = Crap.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @crap }
end
end
# GET /craps/new
# GET /craps/new.xml
def new
@crap = Crap.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @crap }
end
end
# GET /craps/1/edit
def edit
@crap = Crap.find(params[:id])
end
# POST /craps
# POST /craps.xml
def create
@crap = Crap.new(params[:crap])
respond_to do |format|
if @crap.save
flash[:notice] = 'Crap was successfully created.'
format.html { redirect_to(@crap) }
format.xml { render :xml => @crap, :status => :created, :location => @crap }
else
format.html { render :action => "new" }
format.xml { render :xml => @crap.errors, :status => :unprocessable_entity }
end
end
end
# PUT /craps/1
# PUT /craps/1.xml
def update
@crap = Crap.find(params[:id])
respond_to do |format|
if @crap.update_attributes(params[:crap])
flash[:notice] = 'Crap was successfully updated.'
format.html { redirect_to(@crap) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @crap.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /craps/1
# DELETE /craps/1.xml
def destroy
@crap = Crap.find(params[:id])
@crap.destroy
respond_to do |format|
format.html { redirect_to(craps_url) }
format.xml { head :ok }
end
end
end