mirror of
https://github.com/paper-trail-gem/paper_trail.git
synced 2022-11-09 11:33:19 -05:00
Fix NameError when pg is not loaded
Most apps only load a single db adapter gem. A MySQL app, for example will not load the pg gem. See https://github.com/airblade/paper_trail/issues/1022
This commit is contained in:
parent
33f75c6608
commit
932bf22347
1 changed files with 3 additions and 2 deletions
|
@ -7,10 +7,11 @@ module PaperTrail
|
|||
# replaces certain default Active Record serializers
|
||||
# with custom PaperTrail ones.
|
||||
module AttributeSerializerFactory
|
||||
AR_PG_ARRAY_CLASS = "ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array".freeze
|
||||
|
||||
def self.for(klass, attr)
|
||||
active_record_serializer = klass.type_for_attribute(attr)
|
||||
case active_record_serializer
|
||||
when ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array then
|
||||
if active_record_serializer.class.name == AR_PG_ARRAY_CLASS
|
||||
TypeSerializers::PostgresArraySerializer.new(
|
||||
active_record_serializer.subtype,
|
||||
active_record_serializer.delimiter
|
||||
|
|
Loading…
Reference in a new issue