diff --git a/.DS_Store b/.DS_Store index fec39aa..5f3a861 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 23d0db0..cd1d2bc 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -4,7 +4,7 @@ class ProductsController < ApplicationController end def create - @product = Product.new(params_products) + @product = Product.new(product_params) if @product.save redirect_to @product else @@ -24,12 +24,21 @@ class ProductsController < ApplicationController @product = Product.find(params[:id]) end + def update + @product = Product.find(params[:id]) + if @product.update_attributes(product_params) + redirect_to @product + else + render 'edit' + end + end + def delete end private - def params_products + def product_params params.require(:product).permit(:name, :purchase_price, :sale_price, :img_path) end