Class: Spree::Admin::GiftCardsController
- Inherits:
-
BaseController
- Object
- BaseController
- Spree::Admin::GiftCardsController
- Defined in:
- app/controllers/spree/admin/gift_cards_controller.rb
Instance Method Summary collapse
- #deactivate ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #lookup ⇒ Object
- #redeem ⇒ Object
- #send_email ⇒ Object
- #update ⇒ Object
Instance Method Details
#deactivate ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/spree/admin/gift_cards_controller.rb', line 38 def deactivate if @gift_card.deactivate flash[:success] = I18n.t('spree.admin.gift_cards.deactivated_gift_card') redirect_to edit_admin_order_path(@order) else flash[:error] = @gift_card.errors..join(', ').presence || I18n.t('spree.admin.gift_cards.errors.unable_to_reimburse_gift_card') redirect_to edit_admin_order_gift_card_path(@order, @gift_card) end rescue Spree::Reimbursement::IncompleteReimbursementError flash[:error] = I18n.t('spree.admin.gift_cards.errors.unable_to_reimburse_gift_card') redirect_to edit_admin_order_gift_card_path(@order, @gift_card) end |
#edit ⇒ Object
12 13 |
# File 'app/controllers/spree/admin/gift_cards_controller.rb', line 12 def edit end |
#index ⇒ Object
7 8 9 10 |
# File 'app/controllers/spree/admin/gift_cards_controller.rb', line 7 def index @search = Spree::VirtualGiftCard.purchased.ransack(params[:q]) @gift_cards = @search.result.page(params[:page]).per(params[:per_page]) end |
#lookup ⇒ Object
15 16 |
# File 'app/controllers/spree/admin/gift_cards_controller.rb', line 15 def lookup end |
#redeem ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/spree/admin/gift_cards_controller.rb', line 28 def redeem if @gift_card.redeem(@user) flash[:success] = I18n.t('spree.admin.gift_cards.redeemed_gift_card') redirect_to admin_user_store_credits_path(@user) else flash[:error] = I18n.t('spree.admin.gift_cards.errors.unable_to_redeem_gift_card') render :lookup end end |
#send_email ⇒ Object
51 52 53 54 |
# File 'app/controllers/spree/admin/gift_cards_controller.rb', line 51 def send_email @gift_card.send_email redirect_to :back end |
#update ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/spree/admin/gift_cards_controller.rb', line 18 def update if @gift_card.update(gift_card_params) flash[:success] = I18n.t('spree.admin.gift_cards.gift_card_updated') redirect_to edit_admin_order_path(@order) else flash[:error] = @gift_card.errors..join(', ') redirect_to :back end end |