0

编辑:

在尝试使其正常工作时,我完全注释掉了违规行为factory_girl-它仍然给出相同的错误-

cannot load such file -- factory_girl_rails 
/app/lib/tasks/sample_data.rake:1:in require' 

我需要做些什么来让 heroku 使用/查看我更新的文件吗?

操作:

heroku open在浏览器中返回We're sorry, but something went wrong.,并从以下位置返回heroku logs

2013-08-23T21:18:48.870042+00:00 app[web.1]: Started GET "/" for 86.59.188.18 at 2013-08-23 21:18:48 +0000
2013-08-23T21:18:49.388611+00:00 app[web.1]:
2013-08-23T21:18:49.388611+00:00 app[web.1]: ActiveRecord::StatementInvalid (Mysql2::Error: Table 'heroku_9e0ff302f567892.users' doesn't exist: SHOW FULL FIELDS FROM `users`):
2013-08-23T21:18:49.388611+00:00 app[web.1]:   app/models/user.rb:52:in `authenticate_with_salt'
2013-08-23T21:18:49.388611+00:00 app[web.1]:   app/helpers/sessions_helper.rb:62:in `user_from_remember_token'
2013-08-23T21:18:49.388611+00:00 app[web.1]:   app/helpers/sessions_helper.rb:32:in `current_user'
2013-08-23T21:18:49.388611+00:00 app[web.1]:   app/helpers/sessions_helper.rb:13:in `logged_in?'
2013-08-23T21:18:49.388611+00:00 app[web.1]:   app/controllers/pages_controller.rb:32:in `home'
2013-08-23T21:18:49.388611+00:00 app[web.1]:
2013-08-23T21:18:49.388611+00:00 app[web.1]:
2013-08-23T21:18:49.388906+00:00 app[web.1]: Processing by PagesController#home as HTML
2013-08-23T21:18:49.388906+00:00 app[web.1]: Completed 500 Internal Server Error in 5ms
2013-08-23T21:18:49.390347+00:00 heroku[router]: at=info method=GET path=/ host=shrouded-caverns-2325.herokuapp.com fwd="86.59.188.18" dyno=web.1 connect=2ms service=528ms status=500 bytes=643

运行heroku run rake db:schema:load --trace返回:

rake aborted!
cannot load such file -- factory_girl_rails
/app/lib/tasks/sample_data.rake:1:in `require'
/app/lib/tasks/sample_data.rake:1:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:425:in `load'
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:425:in `block in load_tasks'
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:425:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:425:in `load_tasks'
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/application.rb:145:in `load_tasks'
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
/app/Rakefile:7:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:637:in `raw_load_rakefile'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/bin/rake:23:in `load'
/app/vendor/bundle/ruby/2.0.0/bin/rake:23:in `<main>'

抛出工厂女孩错误的文件:

namespace :db do

  desc "Fill db with sample data"

  task :populate, :environment do
    
    require 'factory_girl_rails'

    ...

  end

end

宝石文件:

source 'https://rubygems.org'

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem "autotest"
gem 'autotest-growl'
gem 'webrat'
gem "json", "~> 1.4"
gem "thor", "~> 0.17.0"
gem "cocoon"
gem 'jquery_datepicker'

#DB

gem "mysql2"
gem "pg"

#GROUPS 

#development

group :development do
  
  gem "rspec-rails"
  gem "annotate"
  gem "faker"

end

#test

group :test do
  
  gem "rspec"
  gem 'factory_girl_rails', :require => false

end


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

# gem 'jquery-rails' (http://stackoverflow.com/a/17053795/2128691)
gem 'jquery-rails', '~> 2.3.0'
4

2 回答 2

0

它抛出错误的原因是因为 factory girl rails 仅安装在“测试”模式下。在 heroku 上,除非您另有说明,否则您的应用程序通常处于“生产”模式。我会从填充任务中取出需求。此外,您最好在逐个测试的基础上创建工厂。见https://github.com/thoughtbot/factory_girl/wiki/Usage

另一种选择是在生产模式下安装工厂女孩。简单地将 gem 'factory-girl-rails' 从测试组中取出。

于 2013-08-23T22:15:33.087 回答
0

我花了一段时间才开始工作,但我终于做到了 - 为了解决这个特定的难题,我补充道-/lib这 可能不是每个人的答案,但目前对我来说还不错。 /spec.slugignore

于 2013-08-24T10:43:41.073 回答