Ximik
Ximik

Reputation: 2495

enum_column gem problem

Hello I need enum columns in my tables and so I tried to use this gem. But when I try to make migration I have this and have no idea what to do.

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

Version

rails -v
Rails 3.0.9
ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i486-linux]

Upvotes: 2

Views: 379

Answers (1)

JuanBoca
JuanBoca

Reputation: 724

This is an old question (almost 2 years), but since I came here looking for something similar, I think someone else can have this issue as it is not documented on the gem.

As you didn't show how was your migration, I will give a generic solution:

Just using this in your migration should work:

def up
  change_column :table, :sex, :enum, :limit => ['Male','Female','Unknown'], :default => 'Unknown'
end

That should work!

Upvotes: 1

Related Questions