tap/app/controllers/products_controller.rb
2014-11-25 13:09:55 +01:00

37 lines
598 B
Ruby

class ProductsController < ApplicationController
def new
@product = Product.new
end
def create
@product = Product.new(params_products)
if @product.save
redirect_to @product
else
render "new"
end
end
def show
@product = Product.find(params[:id])
end
def index
@products = Product.all
end
def edit
@product = Product.find(params[:id])
end
def delete
end
private
def params_products
params.require(:product).permit(:name, :purchase_price, :sale_price,
:img_path)
end
end