You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
box-o-sand/rails/map-mash/app/controllers/mashes_controller.rb

86 lines
1.9 KiB

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