gpt4 book ai didi

ruby-on-rails - Rake:当我尝试迁移时说表不存在……不,它不存在,这就是我尝试迁移的原因?

转载 作者:行者123 更新时间:2023-12-04 07:39:35 25 4
gpt4 key购买 nike

命令和跟踪:

% rake db:migrate RAILS_ENV=test --trace
(in /Users/lprestonsegoiii/Work/GravityLabs/TinderBox)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Mysql::Error: Table 'project.medias' doesn't exist: SHOW FIELDS FROM `medias`
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract_adapter.rb:221:in `log'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/mysql_adapter.rb:323:in `execute'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/mysql_adapter.rb:470:in `columns'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:1301:in `columns'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:1314:in `column_names'
/Library/Ruby/Gems/1.8/gems/searchlogic-2.5.6/lib/searchlogic/named_scopes/ordering.rb:33:in `ordering_condition_details'
/Library/Ruby/Gems/1.8/gems/searchlogic-2.5.6/lib/searchlogic/named_scopes/ordering.rb:25:in `create_condition'
/Library/Ruby/Gems/1.8/gems/searchlogic-2.5.6/lib/searchlogic/named_scopes/or_conditions.rb:28:in `create_condition'
/Library/Ruby/Gems/1.8/gems/searchlogic-2.5.6/lib/searchlogic/named_scopes/column_conditions.rb:63:in `respond_to?'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:1511:in `respond_to?'
/Library/Ruby/Gems/1.8/gems/paperclip-2.4.0/lib/paperclip.rb:402:in `attachment_definitions'
/Library/Ruby/Gems/1.8/gems/paperclip-2.4.0/lib/paperclip.rb:283:in `has_attached_file'
/project/app/models/media.rb:23
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:158:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:158:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:265:in `require_or_load'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:425:in `load_missing_constant'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in `const_missing'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:92:in `const_missing'
project/test/factories/general.rb:87 #This is where Media is referenced... but it should have errored about any of the other 10 Models that don't have tables above where this one is used in this file....
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:147:in `load_without_new_constant_marking'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:147:in `load'
/Library/Ruby/Gems/1.8/gems/factory_girl-2.0.5/lib/factory_girl/find_definitions.rb:20:in `find_definitions'
/Library/Ruby/Gems/1.8/gems/factory_girl-2.0.5/lib/factory_girl/find_definitions.rb:19:in `each'
/Library/Ruby/Gems/1.8/gems/factory_girl-2.0.5/lib/factory_girl/find_definitions.rb:19:in `find_definitions'
/Library/Ruby/Gems/1.8/gems/factory_girl-2.0.5/lib/factory_girl/find_definitions.rb:15:in `each'
/Library/Ruby/Gems/1.8/gems/factory_girl-2.0.5/lib/factory_girl/find_definitions.rb:15:in `find_definitions'
/Library/Ruby/Gems/1.8/gems/factory_girl-2.0.5/lib/factory_girl/rails2.rb:6
/Library/Ruby/Gems/1.8/gems/rails-2.3.8/lib/initializer.rb:614:in `call'
/Library/Ruby/Gems/1.8/gems/rails-2.3.8/lib/initializer.rb:614:in `after_initialize'
/Library/Ruby/Gems/1.8/gems/rails-2.3.8/lib/initializer.rb:613:in `each'
/Library/Ruby/Gems/1.8/gems/rails-2.3.8/lib/initializer.rb:613:in `after_initialize'
/Library/Ruby/Gems/1.8/gems/rails-2.3.8/lib/initializer.rb:179:in `process'
/Library/Ruby/Gems/1.8/gems/rails-2.3.8/lib/initializer.rb:113:in `send'
/Library/Ruby/Gems/1.8/gems/rails-2.3.8/lib/initializer.rb:113:in `run'
/project/config/environment.rb:17 #why does it jump into the env? this is irrelevant to raking.
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.3.8/lib/tasks/misc.rake:4
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin//rake:19:in `load'
/usr/bin//rake:19

编辑:第一个迁移文件: http://pastebin.com/49aJe2wv它出错的表甚至还不存在。

测试数据库中没有表。

EDIT2:堆栈跟踪的详细信息工厂/综合:87

Factory.define :media, :class => Media do |m| #line 87 <----
m.name "Alice is in an asian wonderland"
m.document_file_name "alice_test_image.jpeg"
m.document_content_type "image/jpeg"
m.document_file_size "155548"
...
end

编辑3:媒体.rb http://pastebin.com/rZpdBTyq

最佳答案

这看起来像是您的工厂或 factory_girl/factory_girl_rails 的问题。

factory_girl_rails 在启动时加载你所有的工厂,我认为如果它们包括关联、验证等,然后调用 ActiveModel/ActiveRecord 来检查模型。当然,在这种情况下,他们发现没有要检查的数据库。

我有同样的问题,解决方案/解决方法是删除 gem 'factory_girl_rails' 并将其替换为普通的 'factory_girl',然后在 spec_helper 中手动加载工厂:

require 'factory_girl'
FactoryGirl.find_definitions

关于ruby-on-rails - Rake:当我尝试迁移时说表不存在……不,它不存在,这就是我尝试迁移的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7275889/

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