Class: Account::CardsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Account::CardsController
- Defined in:
- app/controllers/tang/account/cards_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/tang/account/cards_controller.rb', line 19 def create @card = SaveCard.call( current_customer, params[:stripe_token] ) if @card.errors.blank? redirect_to account_card_path, notice: 'Card was successfully created.' else render :new end end |
#destroy ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'app/controllers/tang/account/cards_controller.rb', line 45 def destroy if current_customer.subscription.nil? @card.destroy redirect_to account_card_url, notice: 'Card was successfully removed.' else redirect_to account_card_url, notice: 'You cannot remove your card with an active subscription.' end end |
#new ⇒ Object
13 14 15 16 17 |
# File 'app/controllers/tang/account/cards_controller.rb', line 13 def new @card = Card.new( customer: current_customer ) end |
#show ⇒ Object
7 8 9 10 11 |
# File 'app/controllers/tang/account/cards_controller.rb', line 7 def show @can_delete_card = current_customer.stripe_id.present? && current_customer.subscription.nil? && @card.present? end |
#update ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/tang/account/cards_controller.rb', line 32 def update @card = SaveCard.call( current_customer, params[:stripe_token] ) if @card.errors.blank? redirect_to account_card_path, notice: 'Card was successfully created.' else render :new end end |