Call single-use before_filters from actions instead

This commit is contained in:
Rob Harrington
2017-09-11 12:03:53 +10:00
parent 9832966b77
commit 22bbe29f3d
2 changed files with 5 additions and 8 deletions

View File

@@ -11,11 +11,12 @@ class EnterprisesController < BaseController
before_filter :clean_permalink, only: :check_permalink
before_filter :enable_embedded_shopfront
before_filter :set_enterprise, only: :relatives
respond_to :js, only: :permalink_checker
def relatives
set_enterprise
respond_to do |format|
format.json do
enterprises = @enterprise.andand.relatives.andand.activated

View File

@@ -1,8 +1,5 @@
module Spree
class CreditCardsController < BaseController
before_filter :set_credit_card, only: [:destroy]
before_filter :destroy_at_stripe, only: [:destroy]
def new_from_token
# A new Customer is created for every credit card (same as via ActiveMerchant)
# Note that default_source is the card represented by the token
@@ -20,6 +17,9 @@ module Spree
end
def destroy
@credit_card = Spree::CreditCard.find(params[:id])
destroy_at_stripe
if @credit_card.destroy
flash[:success] = I18n.t(:card_has_been_removed, number: "x-#{@credit_card.last_digits}")
else
@@ -58,9 +58,5 @@ module Spree
card.user_id = spree_current_user.id
card
end
def set_credit_card
@credit_card = Spree::CreditCard.find(params[:id])
end
end
end