问题
Edit:
While trying to get this working, I commented out the offending factory_girl
entirely - and it's still giving the same error -
cannot load such file -- factory_girl_rails
/app/lib/tasks/sample_data.rake:1:in require'
is there something i need to do to make heroku work with/see my updated files?
OP:
heroku open
returns We're sorry, but something went wrong.
in the browser and the following from 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
running heroku run rake db:schema:load --trace
returns:
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>'
The file throwing the factory girl error:
namespace :db do
desc "Fill db with sample data"
task :populate, :environment do
require 'factory_girl_rails'
...
end
end
gemfile:
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'
回答1:
The reason its throwing an error is because factory girl rails is only install in "test" mode. On heroku you app is usually in "production" mode unless you specify otherwise. I'd take out the require from the populate task. Also you're probably better off creating factories on a test by test basis. See https://github.com/thoughtbot/factory_girl/wiki/Usage
The other option is to install factory girl in production mode. Simple take the gem 'factory-girl-rails' out of the test group.
回答2:
It took a while to get this working, but I finally did - to solve this particular piece of the puzzle, I added /lib
and /spec
to .slugignore
- that's probably not the answer for everyone, but for the moment it's fine for me.
来源:https://stackoverflow.com/questions/18412099/heroku-open-fails-table-doesnt-exist-error-in-logs