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 75971e4..825feba 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