我在stackoverflow上搜索了一下,没有找到类似的问题。我正在尝试向现有的Slicks表中添加一列。这应该很容易,但我快要急疯了! 可能是我没有给迁移命名良好:rails generate migration AddNametoSlicks name:string
另外: 1.) 这个命令生成了这个迁移20130605194117_add_nameto_slicks.rb, 看起来不对劲,没有_。我把迁移的名称改成了add_name_to_slicks.rb
2.) 迁移命令没有生成add_column。我在命令上有什么遗漏吗?
以下是迁移文件:
class AddNametoSlicks < ActiveRecord::Migration
def change
add_column :slicks, :name, :string
end
end
终端错误:
rake aborted!
An error has occurred, this and all later migrations canceled:
uninitialized constant AddNameToSlicks/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activesupport-3.2.12/lib/active_su
pport/inflector/methods.rb:230:in `block in constantize'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:in `eac
h'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:in `con
stantize'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activesupport-3.2.12/lib/active_support/core_ext/string/inflections.rb:5
4:in `constantize'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/migration.rb:538:in `load_migratio
n'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/migration.rb:533:in `migration'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/migration.rb:528:in `migrate'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/migration.rb:720:in `block (2 leve
ls) in migrate'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/migration.rb:775:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/migration.rb:775:in `block in ddl_
transaction'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/datab
ase_statements.rb:192:in `transaction'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/transactions.rb:208:in `transactio
n'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/migration.rb:775:in `ddl_transacti
on'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/migration.rb:719:in `block in migr
ate'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/migration.rb:700:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/migration.rb:700:in `migrate'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/migration.rb:570:in `up'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/migration.rb:551:in `migrate'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:179:in `bl
ock (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_leve
l'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p194@gigbase/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
Tasks: TOP => db:migrate