有人可以告诉我我做错了吗?
我跑了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:inconst_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:ineach' /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:inconstantize' /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:inmigration' /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:incall' /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:intransaction' /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:inddl_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:ineach' /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:inup' /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:incall' /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:ineach' /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:ininvoke_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:ininvoke_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:ininvoke_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:ineach' /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:instandard_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:inrun' /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:inrun' /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
答案 0 :(得分:4)
你有:
class CreateCityZipMSAs &lt; ActiveRecord的::迁移
错误是:
未初始化的常量 CreateCityZipMsas
尝试将迁移重命名为 CreateCityZipMsas 。