acoustic_north
acoustic_north

Reputation: 845

Rake aborted! wrong constant name 0Bak

I'm having a real problem getting my app to successfully run rake db:migrate after deploying with Capistrano. The app is working fine in development mode, but when I try to deploy onto my Ubuntu 12.04 server I get the following output:

/var/mdnapp/current$ bundle exec rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
rake aborted!
An error has occurred, all later migrations canceled:

wrong constant name 0Bak
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/inflector/methods.rb:229:in `const_defined?'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/inflector/methods.rb:229:in `block in constantize'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/inflector/methods.rb:228:in `each'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/inflector/methods.rb:228:in `constantize'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/migration.rb:522:in `load_migration'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/migration.rb:517:in `migration'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/migration.rb:512:in `migrate'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/migration.rb:704:in `block (2 levels) in migrate'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/migration.rb:761:in `call'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/migration.rb:761:in `ddl_transaction'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/migration.rb:703:in `block in migrate'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/migration.rb:684:in `each'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/migration.rb:684:in `migrate'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/migration.rb:554:in `up'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/migration.rb:535:in `migrate'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/railties/databases.rake:153:in `block (2 levels) in <top (required)>'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/var/mdnapp/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/var/mdnapp/shared/bundle/ruby/1.9.1/bin/rake:23:in `load'
/var/mdnapp/shared/bundle/ruby/1.9.1/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate

I'm running: rails 3.2.2 mysql2 0.3.11 ruby 1.9.3

In searching for answers on this I have run across some comments that talk about incorrect CamelCase for models. I have checked mine and they are all lowercase in the file name (e.g. user.rb) but in the Class name they are CamelCase. The documentation for inflector describes the NameError and defines it as: "NameError is raised when the name is not in CamelCase or the constant is unknown."

http://www.rubydoc.info/github/rails/rails/master/ActiveSupport/Inflector:constantize

But I am not sure where else in my code to look for a possible CamelCase error. I can't figure out what is going on with this. Any help would be greatly appreciated.

Upvotes: 0

Views: 707

Answers (1)

acoustic_north
acoustic_north

Reputation: 845

OK. I found the problem. I had a folder in my db>migrate folder called backup_migrations. I must have created that at some point to store some migrations I wanted to backup while I modified the originals. One of these migrations in this folder was named after the original but with the extension ".0.bak". In any case, I deleted the backup_migrations folder and all works as expected.

So the take away for others who are struggling with similar "rake aborted! wrong constant name" may be to check your migration files for naming or camel case errors. I hope this helps someone else, cost me a lot of time. As it always is with hind sight, the answer seems perfectly obvious now.

Upvotes: 2

Related Questions