Skip to content

Instantly share code, notes, and snippets.

@r38y
Created August 22, 2013 20:13
Show Gist options
  • Save r38y/6312196 to your computer and use it in GitHub Desktop.
Save r38y/6312196 to your computer and use it in GitHub Desktop.
Controller concern for dealing with some range errors from misbehaving visitors.
module Rangy
extend ActiveSupport::Concern
included do
rescue_from ActiveRecord::StatementInvalid, RangeError, ArgumentError do |exception|
if exception.message =~ /is out of range for type integer|invalid offset|invalid value for Integer/
render text: 'Not found', status: :not_found
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment