Poltergeist in the green, and resourceful refactor
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
module Suppliers
|
||||
class ProductsController < Suppliers::ApplicationController
|
||||
layout 'tablet'
|
||||
after_authentication only: [:show, :edit, :update, :destroy] do
|
||||
@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
end
|
||||
|
||||
# GET /products
|
||||
# GET /products.json
|
||||
@@ -16,7 +19,6 @@ module Suppliers
|
||||
# GET /products/1
|
||||
# GET /products/1.json
|
||||
def show
|
||||
@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
@@ -38,13 +40,13 @@ module Suppliers
|
||||
|
||||
# GET /products/1/edit
|
||||
def edit
|
||||
@product = Product.find(params[:id])
|
||||
#@product = Product.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /products
|
||||
# POST /products.json
|
||||
def create
|
||||
@product = Product.new(product_params)
|
||||
#@product = Product.new(product_params)
|
||||
@product.supplier = current_supplier
|
||||
|
||||
respond_to do |format|
|
||||
@@ -61,7 +63,7 @@ module Suppliers
|
||||
# PUT /products/1
|
||||
# PUT /products/1.json
|
||||
def update
|
||||
@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
#@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @product.update_attributes(product_params)
|
||||
@@ -77,12 +79,12 @@ module Suppliers
|
||||
# DELETE /products/1
|
||||
# DELETE /products/1.json
|
||||
def destroy
|
||||
@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
#@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@product.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to suppliers_products_url, notice: t('action.destroy.successfull', model: Product.model_name.human) }
|
||||
format.json { head :no_content }
|
||||
format.json { head :ok }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user