Module: ProperUniquenessValidation
- Defined in:
- lib/proper_uniqueness_validation.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
- .extract_index_name_from_exception(connection, exception) ⇒ Object
- .extract_index_name_from_postgres_exception(exception) ⇒ Object
- .included(base) ⇒ Object
Class Method Details
.extract_index_name_from_exception(connection, exception) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/proper_uniqueness_validation.rb', line 6 def self.extract_index_name_from_exception( connection, exception ) case connection when ActiveRecord::ConnectionAdapters::PostgreSQLAdapter extract_index_name_from_postgres_exception( exception ) else raise exception end end |
.extract_index_name_from_postgres_exception(exception) ⇒ Object
15 16 17 18 |
# File 'lib/proper_uniqueness_validation.rb', line 15 def self.extract_index_name_from_postgres_exception( exception ) match = exception.original_exception.result.error_field( PGresult::PG_DIAG_MESSAGE_PRIMARY ).match(/"([^"]+)"/ ) match[1] end |
.included(base) ⇒ Object
2 3 4 |
# File 'lib/proper_uniqueness_validation.rb', line 2 def self.included( base ) base.extend ClassMethods end |