From 50b94a4ff8a2f462ceb4e8a4f5286683b4ef0e8b Mon Sep 17 00:00:00 2001 From: luu Date: Sat, 13 Dec 2014 16:41:51 +0000 Subject: add tool only if it is not in the toolbox. --- app/controllers/admin/products_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'app/controllers/admin') diff --git a/app/controllers/admin/products_controller.rb b/app/controllers/admin/products_controller.rb index 0c4eb32d..a4f081a6 100644 --- a/app/controllers/admin/products_controller.rb +++ b/app/controllers/admin/products_controller.rb @@ -1,5 +1,7 @@ module Admin class ProductsController < AdminController + attr_reader :product_api + def initialize(product_api = Spank::IOC.resolve(:product_api)) @product_api = product_api super() @@ -10,12 +12,13 @@ module Admin end def show - @product = @product_api.find(params[:id]) + @product = product_api.find(params[:id]) + @tool = Tool.find_by(:asin=>params[:id]) end def create Tool.create(:name=>params[:name],:asin=>params[:asin]) - redirect_to admin_products_path(params[:asin]) + redirect_to admin_product_path(params[:asin]) end end end -- cgit v1.2.3