Class: ProductsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ProductsController
- Defined in:
- app/controllers/products_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/products_controller.rb', line 16 def create @product = Product.new(params[:product]) if @product.save flash[:notice] = "Successfully created product." redirect_to products_url else render :action => 'new' end end |
#destroy ⇒ Object
41 42 43 44 45 46 |
# File 'app/controllers/products_controller.rb', line 41 def destroy @product = Product.find(params[:id]) @product.destroy flash[:notice] = "Successfully destroyed product." redirect_to products_url end |
#edit ⇒ Object
26 27 28 29 |
# File 'app/controllers/products_controller.rb', line 26 def edit @product = Product.find(params[:id]) render :layout => false end |
#index ⇒ Object
3 4 5 |
# File 'app/controllers/products_controller.rb', line 3 def index @products = Product.all end |
#new ⇒ Object
11 12 13 14 |
# File 'app/controllers/products_controller.rb', line 11 def new @product = Product.new render :layout => false end |
#show ⇒ Object
7 8 9 |
# File 'app/controllers/products_controller.rb', line 7 def show @product = Product.find(params[:id]) end |
#update ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/products_controller.rb', line 31 def update @product = Product.find(params[:id]) if @product.update_attributes(params[:product]) flash[:notice] = "Successfully updated product." redirect_to products_url else render :action => 'edit' end end |