gpt4 book ai didi

ruby-on-rails - Rails rake 数据库 :migrate aborts with generated model

转载 作者:行者123 更新时间:2023-12-04 05:49:11 25 4
gpt4 key购买 nike

谁能告诉我我做错了什么?

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

然后运行 ​​rake db:migrate 并得到以下错误

(in /Users/MMyself/app_dev/property) rake aborted! An error has occurred, this and all later migrations canceled:

uninitialized constant 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

我明白了

(in /Users/MMyself/app_dev/property) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! An error has occurred, this and all later migrations canceled:

uninitialized constant 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
execute' /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
execute' /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
invoke' /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

最佳答案

你有:

class CreateCityZipMSAs < ActiveRecord::Migration

错误是:

uninitialized constant CreateCityZipMsas

尝试将您的迁移重命名为 CreateCityZipMsas

关于ruby-on-rails - Rails rake 数据库 :migrate aborts with generated model,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3449549/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com