Class: Storefront::Users::CreditCardsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/workarea/storefront/users/credit_cards_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/workarea/storefront/users/credit_cards_controller.rb', line 9

def create
  @credit_card = current_profile.credit_cards.create(credit_card_params)

  if @credit_card.persisted?
    flash[:success] = t('workarea.storefront.flash_messages.credit_card_saved')
    redirect_to 
  else
    flash[:error] = t('workarea.storefront.flash_messages.credit_card_save_error')
    render :new
  end
end

#destroyObject



37
38
39
40
41
42
43
# File 'app/controllers/workarea/storefront/users/credit_cards_controller.rb', line 37

def destroy
  @credit_card = current_profile.credit_cards.find(params[:id])
  @credit_card.destroy

  flash[:success] = t('workarea.storefront.flash_messages.credit_card_removed')
  redirect_to 
end

#editObject



21
22
23
# File 'app/controllers/workarea/storefront/users/credit_cards_controller.rb', line 21

def edit
  @credit_card = current_profile.credit_cards.find(params[:id])
end

#newObject



6
7
# File 'app/controllers/workarea/storefront/users/credit_cards_controller.rb', line 6

def new
end

#updateObject



25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/workarea/storefront/users/credit_cards_controller.rb', line 25

def update
  @credit_card = current_profile.credit_cards.find(params[:id])

  if @credit_card.update_attributes(credit_card_params)
    flash[:success] = t('workarea.storefront.flash_messages.credit_card_updated')
    redirect_to 
  else
    flash[:error] = t('workarea.storefront.flash_messages.credit_card_update_error')
    render :edit
  end
end