您好我需要在我的表中使用枚举列,所以我尝试使用这个gem。但是当我尝试进行迁移时,我有这个并且不知道该怎么做。
rake db:migrate --trace
rake aborted!
undefined method `type_to_sql' for module `ActiveRecord::ConnectionAdapters::SchemaStatements'
/var/lib/gems/1.8/gems/enum_column-0.1.6/lib/enum_column/schema_statements.rb:4
/var/lib/gems/1.8/gems/enum_column-0.1.6/lib/enum_column.rb:7:in `require'
/var/lib/gems/1.8/gems/enum_column-0.1.6/lib/enum_column.rb:7
/var/lib/gems/1.8/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
/var/lib/gems/1.8/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
/var/lib/gems/1.8/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'
/var/lib/gems/1.8/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `require'
/var/lib/gems/1.8/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'
/var/lib/gems/1.8/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `require'
/var/lib/gems/1.8/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'
/var/www/my_app/config/application.rb:7
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
/var/www/my_app/Rakefile:4
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:78:in `load_rakefile'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:61:in `run'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/var/lib/gems/1.8/gems/rake-0.9.2/bin/rake:32
/var/lib/gems/1.8/bin/rake:19:in `load'
/var/lib/gems/1.8/bin/rake:19
版
rails -v
Rails 3.0.9
ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i486-linux]
答案 0 :(得分:1)
这是一个老问题(差不多2年),但是因为我来到这里寻找类似的东西,我认为其他人可以解决这个问题,因为宝石上没有记录。
由于您没有展示您的迁移情况,我将提供一个通用的解决方案:
只需在迁移中使用此功能即可:
def up
change_column :table, :sex, :enum, :limit => ['Male','Female','Unknown'], :default => 'Unknown'
end
这应该有用!