耙子流产!错误的常量名称0Bak

时间:2013-01-27 07:21:45

标签: ruby-on-rails-3.2 rake

我在使用Capistrano部署后,让我的应用成功运行rake db:migrate时遇到了实际问题。该应用程序在开发模式下工作正常,但当我尝试部署到我的Ubuntu 12.04服务器上时,我得到以下输出:

/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

我正在跑步: 轨道3.2.2 mysql2 0.3.11 红宝石1.9.3

在搜索这个问题的答案时,我遇到了一些关于模型不正确的CamelCase的评论。我检查了我的文件名(例如user.rb),它们都是小写的,但在类名中它们是CamelCase。 inflector的文档描述了NameError并将其定义为:&#34;当名称不在CamelCase中或者常量未知时引发NameError。&#34;

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

但是我不确定我的代码中还有哪些地方可以查找可能的CamelCase错误。我无法弄清楚这是怎么回事。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:2)

行。我发现了这个问题。我的db&gt; migrate文件夹中有一个名为backup_migrations的文件夹。我必须创建,在某些时候存储我想要备份的一些迁移,同时我修改了原件。此文件夹中的其中一个迁移以原始文件命名,但扩展名为“.0.bak”。无论如何,我删除了backup_migrations文件夹,并且所有文件都按预期工作。

因此,对于那些正在努力解决类似“rake aborted!错误常量名称”的人而言,可能会检查您的迁移文件是否存在命名或驼峰错误。我希望这可以帮助别人,花了我很多时间。因为它始终伴随着后视,现在答案似乎非常明显。