Class: Spree::Admin::ProductsController
- Inherits:
-
ResourceController
- Object
- ApplicationController
- BaseController
- BaseController
- ResourceController
- Spree::Admin::ProductsController
- Defined in:
- app/controllers/spree/admin/products_controller.rb
Instance Method Summary collapse
- #clone ⇒ Object
-
#destroy ⇒ Object
override the destory method to set deleted_at value instead of actually deleting the product.
- #index ⇒ Object
Methods inherited from ResourceController
belongs_to, create, #create, destroy, #edit, #new, new_action, update, #update
Methods included from Core::ControllerHelpers
Instance Method Details
#clone ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/spree/admin/products_controller.rb', line 33 def clone @new = @product.duplicate if @new.save flash.notice = I18n.t('notice_messages.product_cloned') else flash.notice = I18n.t('notice_messages.product_not_cloned') end respond_with(@new) { |format| format.html { redirect_to edit_admin_product_url(@new) } } end |
#destroy ⇒ Object
override the destory method to set deleted_at value instead of actually deleting the product.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/spree/admin/products_controller.rb', line 19 def destroy @product = Product.find_by_permalink!(params[:id]) @product.update_attribute(:deleted_at, Time.now) @product.variants_including_master.update_all(:deleted_at => Time.now) flash.notice = I18n.t('notice_messages.product_deleted') respond_with(@product) do |format| format.html { redirect_to collection_url } format.js { render_js_for_destroy } end end |
#index ⇒ Object
10 11 12 13 14 15 |
# File 'app/controllers/spree/admin/products_controller.rb', line 10 def index respond_with(@collection) do |format| format.html format.json { render :json => json_data } end end |