cours0708/P5B/ruby/mon_projet/app/controllers/admin/suppliers_controller.rb

81 lines
1.9 KiB
Ruby
Raw Permalink Normal View History

2008-11-25 21:11:16 +00:00
#class SuppliersController < ApplicationController
class Admin::SuppliersController < Admin::AdminController
# GET /suppliers
# GET /suppliers.xml
def index
@suppliers = Supplier.find(:all)
respond_to do |format|
format.html # index.rhtml
format.xml { render :xml => @suppliers.to_xml }
end
end
# GET /suppliers/1
# GET /suppliers/1.xml
def show
@supplier = Supplier.find(params[:id])
respond_to do |format|
format.html # show.rhtml
format.xml { render :xml => @supplier.to_xml }
end
end
# GET /suppliers/new
def new
@supplier = Supplier.new
end
# GET /suppliers/1;edit
def edit
@supplier = Supplier.find(params[:id])
end
# POST /suppliers
# POST /suppliers.xml
def create
@supplier = Supplier.new(params[:supplier])
respond_to do |format|
if @supplier.save
flash[:notice] = 'Supplier was successfully created.'
format.html { redirect_to supplier_url(@supplier) }
format.xml { head :created, :location => supplier_url(@supplier) }
else
format.html { render :action => "new" }
format.xml { render :xml => @supplier.errors.to_xml }
end
end
end
# PUT /suppliers/1
# PUT /suppliers/1.xml
def update
@supplier = Supplier.find(params[:id])
respond_to do |format|
if @supplier.update_attributes(params[:supplier])
flash[:notice] = 'Supplier was successfully updated.'
format.html { redirect_to supplier_url(@supplier) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @supplier.errors.to_xml }
end
end
end
# DELETE /suppliers/1
# DELETE /suppliers/1.xml
def destroy
@supplier = Supplier.find(params[:id])
@supplier.destroy
respond_to do |format|
format.html { redirect_to suppliers_url }
format.xml { head :ok }
end
end
end