1685ca58ae1002bd26a6e812a62ec4f94c1e41fe
1 class ProductsController
< ApplicationController
5 @products = Product
.find(:all)
8 format
.html
# index.html.erb
9 format
.xml
{ render
:xml => @products }
16 @product = Product
.find(params
[:id])
18 respond_to
do |format
|
19 format
.html
# show.html.erb
20 format
.xml
{ render
:xml => @product }
25 # GET /products/new.xml
27 @product = Product
.new
29 respond_to
do |format
|
30 format
.html
# new.html.erb
31 format
.xml
{ render
:xml => @product }
35 # GET /products/1/edit
37 @product = Product
.find(params
[:id])
43 @product = Product
.new(params
[:product])
45 respond_to
do |format
|
47 flash
[:notice] = 'Product was successfully created.'
48 format
.html
{ redirect_to(@product) }
49 format
.xml
{ render
:xml => @product, :status => :created, :location => @product }
51 format
.html
{ render
:action => "new" }
52 format
.xml
{ render
:xml => @product.errors
, :status => :unprocessable_entity }
60 @product = Product
.find(params
[:id])
62 respond_to
do |format
|
63 if @product.update_attributes(params
[:product])
64 flash
[:notice] = 'Product was successfully updated.'
65 format
.html
{ redirect_to(@product) }
66 format
.xml
{ head
:ok }
68 format
.html
{ render
:action => "edit" }
69 format
.xml
{ render
:xml => @product.errors
, :status => :unprocessable_entity }
75 # DELETE /products/1.xml
77 @product = Product
.find(params
[:id])
80 respond_to
do |format
|
81 format
.html
{ redirect_to(products_url
) }
82 format
.xml
{ head
:ok }