Skip to content

Instantly share code, notes, and snippets.

@jsmestad
Last active December 29, 2015 03:08
Show Gist options
  • Save jsmestad/7605182 to your computer and use it in GitHub Desktop.
Save jsmestad/7605182 to your computer and use it in GitHub Desktop.
PG patch for StatementInvalid when using UUIDs or non-standard primary keys (PK)
# config/initializers/postgresql_patch.rb
#
class ActiveRecord::ConnectionAdapters::AbstractAdapter
def translate_exception(exception, message)
if exception.is_a?(PG::InvalidTextRepresentation)
raise ActiveRecord::RecordNotFound
else
# override in derived class
ActiveRecord::StatementInvalid.new(message, exception)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment