Class: Spree::Admin::GiftCardsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/admin/gift_cards_controller.rb

Instance Method Summary collapse

Instance Method Details

#editObject



12
13
# File 'app/controllers/spree/admin/gift_cards_controller.rb', line 12

def edit
end

#indexObject



7
8
9
10
# File 'app/controllers/spree/admin/gift_cards_controller.rb', line 7

def index
  @search = Spree::VirtualGiftCard.purchased.search(params[:q])
  @gift_cards = @search.result.page(params[:page]).per(params[:per_page])
end

#lookupObject



15
16
# File 'app/controllers/spree/admin/gift_cards_controller.rb', line 15

def lookup
end

#redeemObject



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] = Spree.t("admin.gift_cards.redeemed_gift_card")
    redirect_to admin_user_store_credits_path(@user)
  else
    flash[:error] = Spree.t("admin.gift_cards.errors.unable_to_redeem_gift_card")
    render :lookup
  end
end

#send_emailObject



38
39
40
41
# File 'app/controllers/spree/admin/gift_cards_controller.rb', line 38

def send_email
  @gift_card.send_email
  redirect_to :back
end

#updateObject



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_attributes(gift_card_params)
    flash[:success] = Spree.t("admin.gift_cards.gift_card_updated")
    redirect_to edit_admin_order_path(@order)
  else
    flash[:error] = @gift_card.errors.full_messages.join(", ")
    redirect_to :back
  end
end