product edit fixed
This commit is contained in:
parent
95ea927ba2
commit
2575133ce2
2 changed files with 11 additions and 2 deletions
BIN
.DS_Store
vendored
BIN
.DS_Store
vendored
Binary file not shown.
|
@ -4,7 +4,7 @@ class ProductsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@product = Product.new(params_products)
|
@product = Product.new(product_params)
|
||||||
if @product.save
|
if @product.save
|
||||||
redirect_to @product
|
redirect_to @product
|
||||||
else
|
else
|
||||||
|
@ -24,12 +24,21 @@ class ProductsController < ApplicationController
|
||||||
@product = Product.find(params[:id])
|
@product = Product.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@product = Product.find(params[:id])
|
||||||
|
if @product.update_attributes(product_params)
|
||||||
|
redirect_to @product
|
||||||
|
else
|
||||||
|
render 'edit'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def params_products
|
def product_params
|
||||||
params.require(:product).permit(:name, :purchase_price, :sale_price,
|
params.require(:product).permit(:name, :purchase_price, :sale_price,
|
||||||
:img_path)
|
:img_path)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue