how (replace|create) an enum field on rails 2.0 migrations?

后端 未结 10 1598
轮回少年
轮回少年 2020-12-07 10:27

I would like to create an enum field at sone migration I\'m doing, I tried searching in google but I can\'t find the way to do it in the migration

the only thing I f

10条回答
  •  有刺的猬
    2020-12-07 10:52

    Add the following:

    module ActiveRecord
      module ConnectionAdapters #:nodoc:
        class TableDefinition
          def enum(*args)
            options = args.extract_options!
            column_names = args
    
            column_names.each { |name| column(name, 'enum', options) }
          end
        end
      end
    end
    

    to lib/enum/table_definition.rb and include it in your init.rb.

提交回复
热议问题