Class: Admin::ProductsController
- Defined in:
- app/controllers/admin/products_controller.rb
Instance Method Summary collapse
-
#destroy ⇒ Object
override the destory method to set deleted_at value instead of actually deleting the product.
Instance Method Details
#destroy ⇒ Object
override the destory method to set deleted_at value instead of actually deleting the product.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/admin/products_controller.rb', line 36 def destroy @product = Product.find_by_permalink(params[:id]) @product.deleted_at = Time.now() @product.variants.each do |v| v.deleted_at = Time.now() v.save end if @product.save flash[:notice] = "Product has been deleted" else flash[:notice] = "Product could not be deleted" end redirect_to collection_url end |