Skip to content

Instantly share code, notes, and snippets.

@Kievbuy
Last active November 26, 2018 13:23
Show Gist options
  • Select an option

  • Save Kievbuy/30b75fee26401c0b86de8588d6c52581 to your computer and use it in GitHub Desktop.

Select an option

Save Kievbuy/30b75fee26401c0b86de8588d6c52581 to your computer and use it in GitHub Desktop.
# Add to app/controllers/application_controller.rb
if Rails.env.production? || Rails.env.staging?
# https://api.rubyonrails.org/v4.2/classes/ActiveSupport/Rescuable/ClassMethods.html
# https://api.rubyonrails.org/v5.2/classes/ActiveSupport/Rescuable/ClassMethods.html#method-i-rescue_from
rescue_from Exception do |exception|
render_error(exception, 500)
end
rescue_from ActionController::RoutingError,
ActionController::UnknownFormat,
AbstractController::ActionNotFound,
ActiveRecord::RecordNotFound do |exception|
render_error(exception, 404)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment