Qwaiter in the green 💚

This commit is contained in:
2013-12-22 15:20:14 +01:00
parent 76c2d4ddbc
commit 69132b0c07
20 changed files with 150 additions and 935 deletions
+20 -16
View File
@@ -6,46 +6,46 @@ module Admin
# GET /products.json
def index
@products = Product.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @products }
end
end
# GET /products/1
# GET /products/1.json
def show
@product = Product.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @product }
end
end
# GET /products/new
# GET /products/new.json
def new
@product = Product.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @product }
end
end
# GET /products/1/edit
def edit
@product = Product.find(params[:id])
end
# POST /products
# POST /products.json
def create
@product = Product.new(params[:product])
@product = Product.new(product_params)
@product.supplier_id = params[:product][:supplier_id]
respond_to do |format|
if @product.save
format.html { redirect_to [:admin, @product], notice: t('action.create.successfull', model: Product.model_name.human) }
@@ -56,14 +56,14 @@ module Admin
end
end
end
# PUT /products/1
# PUT /products/1.json
def update
@product = Product.find(params[:id])
respond_to do |format|
if @product.update_attributes(params[:product])
if @product.update_attributes(product_params)
format.html { redirect_to [:admin, @product], notice: t('action.update.successfull', model: Product.model_name.human) }
format.json { head :no_content }
else
@@ -72,24 +72,28 @@ module Admin
end
end
end
# DELETE /products/1
# DELETE /products/1.json
def destroy
@product = Product.find(params[:id])
@product.destroy
respond_to do |format|
format.html { redirect_to admin_products_path, notice: t('action.destroy.successfull', model: Product.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@suppliers = Supplier.all
@product_categories = ProductCategory.all
end
def product_params
params.require(:product).permit!
end
end
end