Skip to content

Commit

Permalink
Merge pull request #2068 from jhawthorn/record_ip_address
Browse files Browse the repository at this point in the history
Avoid running validations in current_order
  • Loading branch information
gmacdougall authored Jul 10, 2017
2 parents b3f1128 + a5828b8 commit 297a873
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,12 @@ def add_default_payment_from_wallet
alias_method :assign_default_credit_card, :add_default_payment_from_wallet
deprecate assign_default_credit_card: :add_default_payment_from_wallet, deprecator: Spree::Deprecation

def record_ip_address(ip_address)
if last_ip_address != ip_address
update_attributes!(last_ip_address: ip_address)
end
end

private

def process_payments_before_complete
Expand Down
2 changes: 1 addition & 1 deletion core/lib/spree/core/controller_helpers/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def current_order(options = {})
end

if @current_order
@current_order.update(last_ip_address: ip_address)
@current_order.record_ip_address(ip_address)
return @current_order
end
end
Expand Down

0 comments on commit 297a873

Please sign in to comment.