Skip to content

Instantly share code, notes, and snippets.

@gma
Forked from Bartuz/checkout_controller.rb
Last active December 2, 2015 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gma/2dcc96d14d0fd4cb94c3 to your computer and use it in GitHub Desktop.
Save gma/2dcc96d14d0fd4cb94c3 to your computer and use it in GitHub Desktop.
# https://www.agileplannerapp.com/blog/building-agile-planner/refactoring-with-hexagonal-rails
def checkout
cart = CartCheckout.new(many, params)
cart.save!
rescue OutOfStock => e
OutOfStockNotification.new(e.line_item).deliver
redirect_to cart_path, notice: t('.failure', reason: cart.error_message)
rescue CartError
redirect_to cart_path, notice: t('.failure', reason: cart.error_message)
else
redirect_to cart_path, notice: t('.success')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment