Class: Admin::VariantsController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::VariantsController
- Defined in:
- app/controllers/admin/variants_controller.rb
Instance Method Summary collapse
-
#destroy ⇒ Object
override the destory method to set deleted_at value instead of actually deleting the product.
- #update_positions ⇒ Object
Instance Method Details
#destroy ⇒ Object
override the destory method to set deleted_at value instead of actually deleting the product.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/admin/variants_controller.rb', line 23 def destroy @variant = Variant.find(params[:id]) @variant.deleted_at = Time.now() if @variant.save flash.notice = I18n.t("notice_messages.variant_deleted") else flash.notice = I18n.t("notice_messages.variant_not_deleted") end respond_to do |format| format.html { redirect_to admin_product_variants_url(params[:product_id]) } format.js { render_js_for_destroy } end end |
#update_positions ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/admin/variants_controller.rb', line 39 def update_positions params[:positions].each do |id, index| Variant.update_all(['position=?', index], ['id=?', id]) end respond_to do |format| format.html { redirect_to admin_product_variants_url(params[:product_id]) } format.js { render :text => 'Ok' } end end |