diff options
| author | luu <luuduong@gmail.com> | 2014-12-13 16:41:51 +0000 |
|---|---|---|
| committer | luu <luuduong@gmail.com> | 2014-12-13 16:41:51 +0000 |
| commit | 50b94a4ff8a2f462ceb4e8a4f5286683b4ef0e8b (patch) | |
| tree | d87c96d5a1328812ead05464d26e64bbb842373a /app | |
| parent | 0a61f5240d1fa127a9bb9bdd0a39ffd84dc8bfb9 (diff) | |
add tool only if it is not in the toolbox.
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/admin/products_controller.rb | 7 | ||||
| -rw-r--r-- | app/views/admin/products/show.html.erb | 12 |
2 files changed, 13 insertions, 6 deletions
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 diff --git a/app/views/admin/products/show.html.erb b/app/views/admin/products/show.html.erb index b596a3de..58852dab 100644 --- a/app/views/admin/products/show.html.erb +++ b/app/views/admin/products/show.html.erb @@ -22,10 +22,14 @@ Add to tools: </td> <td> - <%= form_tag admin_products_path do %> - <%= text_field_tag :name, @product.item_attributes['title'] %> - <%= hidden_field_tag "asin", @product.asin %> - <%= submit_tag "Add to tools" %> + <% if @tool.present? %> + In the toolbox as <%= @tool.name %> + <% else %> + <%= form_tag admin_products_path do %> + <%= text_field_tag :name, @product.item_attributes['title'] %> + <%= hidden_field_tag "asin", @product.asin %> + <%= submit_tag "Add to tools" %> + <% end %> <% end %> </td> </tr> |
