]> git.openstreetmap.org Git - rails.git/commitdiff
Monkey patch PostgreSQLAdapter to make enums work
authorTom Hughes <tom@compton.nu>
Thu, 27 Jun 2013 17:09:28 +0000 (18:09 +0100)
committerTom Hughes <tom@compton.nu>
Sat, 21 Sep 2013 10:35:45 +0000 (11:35 +0100)
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