在使用 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
我正在运行:rails 3.2.2 mysql2 0.3.11 ruby 1.9.3
在寻找这方面的答案时,我遇到了一些关于模型不正确的 CamelCase 的评论。我检查了我的,它们在文件名中都是小写的(例如 user.rb),但在类名中它们是 CamelCase。变形器的文档描述了 NameError 并将其定义为:“当名称不在 CamelCase 中或常量未知时引发 NameError。”
http://www.rubydoc.info/github/rails/rails/master/ActiveSupport/Inflector:constantize
但我不确定我的代码中还有哪些地方可以查找可能的 CamelCase 错误。我无法弄清楚这是怎么回事。任何帮助将不胜感激。