Skip to content

Instantly share code, notes, and snippets.

@sirupsen
Created January 13, 2015 16:49
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 sirupsen/f3111d7f12f9d736d68a to your computer and use it in GitHub Desktop.
Save sirupsen/f3111d7f12f9d736d68a to your computer and use it in GitHub Desktop.
def load_customer
if customer_id = session[:customer_id]
@customer = Customer.find_by_id(session[:customer_id])
end
# in reality e.g. a redis exception thrown from the driver
# could be raised from circuit breaker or semian as well (see later)
rescue Sessions::DataStoreUnavailable
flash[:notice] = 'Customer sign in is currently unavailable'
@customer = nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment