]> git.openstreetmap.org Git - rails.git/blobdiff - config/initializers/postgresql_adapter.rb
Monkey patch PostgreSQLAdapter to make enums work
[rails.git] / config / initializers / postgresql_adapter.rb
index 75971e4bf115980f294c7e591b299a8434c7591b..825feba8bd3b0cbe885bd397dc23a1f7bdefc6be 100644 (file)
@@ -59,6 +59,19 @@ if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
           nil
         end
       end
+
+      class PostgreSQLColumn
+        def simplified_type_with_enum(field_type)
+          case field_type
+          when /_enum$/
+            :string
+          else
+            simplified_type_without_enum(field_type)
+          end
+        end
+
+        alias_method_chain :simplified_type, :enum
+      end
     end
   end
 end