Skip to content

Loading…

Rescue from shipping error in orders controllers. #45

Merged
merged 1 commit into from

2 participants

@j15e

Shipping price may be calculated when adding products to order if user is logged & address is filled.

Think it might be better for users to redirect them to request.referrer but redirecting to referrer doesn't seems to be a really good practice.

@j15e j15e Rescue from shipping error in orders controllers.
Shipping price may be calculated when adding products to order if user is logged & address is filled.
0a032f5
@jumph4x

@j15e is in a roll :boom:

@jumph4x jumph4x merged commit 7c44b7e into spree-contrib:master

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 4, 2012
  1. @j15e

    Rescue from shipping error in orders controllers.

    j15e committed
    Shipping price may be calculated when adding products to order if user is logged & address is filled.
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 0 deletions.
  1. +11 −0 app/controllers/spree/orders_controller_decorator.rb
View
11 app/controllers/spree/orders_controller_decorator.rb
@@ -0,0 +1,11 @@
+# handle shipping errors gracefully during order update
+Spree::OrdersController.class_eval do
+
+ rescue_from Spree::ShippingError, :with => :handle_shipping_error
+
+ private
+ def handle_shipping_error(e)
+ flash[:error] = e.message
+ redirect_back_or_default(root_path)
+ end
+end
Something went wrong with that request. Please try again.