Rails rake db:使用生成的模型迁移中止

时间:2010-08-10 13:41:38

标签: ruby-on-rails migration

有人可以告诉我我做错了吗?

我跑了script/generate model CityZipMSA city:string state:string zip:integer MSA:integer

然后运行rake db:migrate我收到以下错误

  

(在/ Users / MMyself / app_dev / property中)   耙子流产了!   发生错误,此操作和所有后​​续迁移都已取消:

     

未初始化的常量CreateCityZipMsas

我的迁移文件:

    class CreateCityZipMSAs < ActiveRecord::Migration
  def self.up
    create_table :city_zip_msas do |t|
      t.string :city
      t.string :state
      t.integer :zip
      t.integer :MSA

      t.timestamps
    end
  end

  def self.down
    drop_table :city_zip_msas
  end
end

当我运行rake db:migrate --trace

我得到了

  

(在/ Users / MMyself / app_dev / property中)   **调用db:migrate(first_time)   **调用环境(first_time)   **执行环境   **执行db:migrate   耙子流产了!   发生错误,此操作和所有后​​续迁移都已取消:

     

未初始化的常量CreateCityZipMsas   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:443:in load_missing_constant' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in const_missing'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:92:in const_missing' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-2.3.8/lib/active_support/inflector.rb:364:in constantize'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-2.3.8/lib/active_support/inflector.rb:363:in each' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-2.3.8/lib/active_support/inflector.rb:363:in constantize'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-2.3.8/lib/active_support/core_ext/string/inflections.rb:162:in constantize' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:374:in load_migration'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:369:in migration' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:365:in migrate'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:491   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:565:in call' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:565:in ddl_transaction'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in transaction' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/transactions.rb:182:in transaction'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:565:in ddl_transaction' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:490:in migrate'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:477:in each' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record>/migration.rb:477:in migrate'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:401:in up' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:383:in migrate'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rails-2.3.8/lib/tasks/databases.rake:112   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:636:in call' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:636:in执行'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:631:in each' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:631:in执行'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:597:in invoke_with_call_chain' /Users/MMyself/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/monitor.rb:242:in synchronize'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:583:in调用'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2051:in invoke_task' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2029:in top_level'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2029:in each' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2029:in top_level'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2023:in top_level'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2001:in run' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling'   /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:1998:in run' /Users/MMyself/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/bin/rake:31 /Users/MMyself/.rvm/rubies/ruby-1.8.7-p249/bin/rake:24:in load'   /Users/MMyself/.rvm/rubies/ruby-1.8.7-p249/bin/rake:24

1 个答案:

答案 0 :(得分:4)

你有:

  

class CreateCityZipMSAs &lt; ActiveRecord的::迁移

错误是:

  

未初始化的常量 CreateCityZipMsas

尝试将迁移重命名为 CreateCityZipMsas