Last active
December 29, 2015 03:08
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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