Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

uninitialized constant ClassName::Enum #56

Open
fleck opened this issue May 4, 2012 · 3 comments
Open

uninitialized constant ClassName::Enum #56

fleck opened this issue May 4, 2012 · 3 comments

Comments

@fleck
Copy link

fleck commented May 4, 2012

I have the class below

class User
include DataMapper::Resource

property :id, Serial

property :display, Enum[ :first, :last, :first_last, :last_first ]

end

When I try and run rake db:autoupgrade I get the following error message: uninitialized constant User::Enum

Below is the trace from rake:

** Invoke db:autoupgrade (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant User::Enum
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/dm-core-1.2.0/lib/dm-core/model.rb:728:in const_missing' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/dm-core-1.2.0/lib/dm-core/property/lookup.rb:25:inconst_missing'
/Users/Jon/addtoit/app/models/user.rb:7:in <class:User>' /Users/Jon/addtoit/app/models/user.rb:1:in<top (required)>'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/dm-rails-1.2.1/lib/dm-rails/setup.rb:60:in block (2 levels) in preload_models' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/dm-rails-1.2.1/lib/dm-rails/setup.rb:60:ineach'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/dm-rails-1.2.1/lib/dm-rails/setup.rb:60:in block in preload_models' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/dm-rails-1.2.1/lib/dm-rails/setup.rb:59:ineach'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/dm-rails-1.2.1/lib/dm-rails/setup.rb:59:in preload_models' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/dm-rails-1.2.1/lib/dm-rails/railtie.rb:80:inblock (2 levels) in class:Railtie'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:418:in _run__2565405975579041820__prepare__1633098324659922499__callbacks' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in__run_callback'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in _run_prepare_callbacks' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:inrun_callbacks'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:74:in prepare!' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:48:inprepare!'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/railties-3.2.3/lib/rails/application/finisher.rb:47:in block in <module:Finisher>' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/railties-3.2.3/lib/rails/initializable.rb:30:ininstance_exec'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/railties-3.2.3/lib/rails/initializable.rb:30:in run' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/railties-3.2.3/lib/rails/initializable.rb:55:inblock in run_initializers'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/railties-3.2.3/lib/rails/initializable.rb:54:in each' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/railties-3.2.3/lib/rails/initializable.rb:54:inrun_initializers'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/railties-3.2.3/lib/rails/application.rb:136:in initialize!' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:inmethod_missing'
/Users/Jon/addtoit/config/environment.rb:5:in <top (required)>' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/railties-3.2.3/lib/rails/application.rb:103:inrequire'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/railties-3.2.3/lib/rails/application.rb:103:in require_environment!' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/railties-3.2.3/lib/rails/application.rb:292:inblock (2 levels) in initialize_tasks'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/task.rb:205:in call' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/task.rb:205:inblock in execute'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/task.rb:200:in each' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/task.rb:200:inexecute'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/task.rb:158:in block in invoke_with_call_chain' /Users/Jon/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/monitor.rb:211:inmon_synchronize'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/task.rb:151:in invoke_with_call_chain' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/task.rb:176:inblock in invoke_prerequisites'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/task.rb:174:in each' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/task.rb:174:ininvoke_prerequisites'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/task.rb:157:in block in invoke_with_call_chain' /Users/Jon/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/monitor.rb:211:inmon_synchronize'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/task.rb:151:in invoke_with_call_chain' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/task.rb:144:ininvoke'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/application.rb:116:in invoke_task' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/application.rb:94:inblock (2 levels) in top_level'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/application.rb:94:in each' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/application.rb:94:inblock in top_level'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/application.rb:133:in standard_exception_handling' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/application.rb:88:intop_level'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/application.rb:66:in block in run' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/application.rb:133:instandard_exception_handling'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/lib/rake/application.rb:63:in run' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/gems/rake-0.9.2.2/bin/rake:33:in<top (required)>'
/Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/bin/rake:19:in load' /Users/Jon/.rvm/gems/ruby-1.9.3-p125@rails32/bin/rake:19:in

'
Tasks: TOP => db:autoupgrade => environment

I'm using rails 3.2.3, if any more information is needed let me know.

@ghost
Copy link

ghost commented Aug 8, 2012

I'm having the same issue. Any updates?

@dkubb
Copy link
Member

dkubb commented Aug 8, 2012

Is dm-types listed somewhere in your Gemfile.lock? It's required to make the Enum type available when defining your models.

@ghost
Copy link

ghost commented Aug 10, 2012

Should mention I use padrino, but above error occurs when trying to upgrade using migrations. No problem using Enum in my models so I guess it is purely a migrations problem.

Yes it is listed in my Gemfile.lock file. It worked before I updated ruby/gem/padrino packages on my Ubuntu.

I fixed it temporarily by using DataMapper::Property::Enum instead of just Enum.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants