Provide a sensible flash message when CreditCard#destroy action fails

This commit is contained in:
Rob Harrington
2017-07-07 15:27:01 +10:00
parent 28ba05ec6b
commit a68ae1fe2d
2 changed files with 4 additions and 1 deletions

View File

@@ -22,8 +22,10 @@ module Spree
def destroy
if @credit_card.destroy
flash[:success] = I18n.t(:card_has_been_removed, number: "x-#{@credit_card.last_digits}")
redirect_to "/account#/cards"
else
flash[:error] = I18n.t(:card_could_not_be_removed)
end
redirect_to "/account#/cards"
end
# Currently can only destroy the whole customer object

View File

@@ -903,6 +903,7 @@ en:
you_have_no_saved_cards: You haven't saved any cards yet
saving_credit_card: Saving credit card...
card_has_been_removed: "Your card has been removed (number: %{number})"
card_could_not_be_removed: Sorry, the card could not be removed
ie_warning_headline: "Your browser is out of date :-("
ie_warning_text: "For the best Open Food Network experience, we strongly recommend upgrading your browser:"