Class: Admin::ProductsController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Admin::ProductsController
- Defined in:
- app/controllers/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
Instance Method Details
#clone ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/admin/products_controller.rb', line 36 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.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/admin/products_controller.rb', line 15 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 = I18n.t("notice_messages.product_deleted") else flash.notice = I18n.t("notice_messages.product_not_deleted") end respond_with(@product) do |format| format.html { redirect_to collection_url } format.js { render_js_for_destroy } end end |
#index ⇒ Object
6 7 8 9 10 11 |
# File 'app/controllers/admin/products_controller.rb', line 6 def index respond_with(@collection) do |format| format.html format.json { render :json => json_data } end end |