当rails应用程序在heroku上部署时出现问题

时间:2013-09-25 07:30:52

标签: ruby-on-rails heroku

heroku日志:

2013-09-25T07:24:45.386731+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
2013-09-25T07:24:45.386731+00:00 app[web.1]:    bin/rails:4:in `require'
2013-09-25T07:24:45.386731+00:00 app[web.1]:    bin/rails:4:in `<main>'
2013-09-25T07:24:46.388163+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 10319 -e $RAILS_ENV`
2013-09-25T07:24:46.764609+00:00 heroku[web.1]: Process exited with status 143
2013-09-25T07:24:50.837146+00:00 app[web.1]: [2013-09-25 07:24:50] INFO  WEBrick 1.3.1
2013-09-25T07:24:50.837146+00:00 app[web.1]: [2013-09-25 07:24:50] INFO  ruby 2.0.0 (2013-06-27) [x86_64-linux]
2013-09-25T07:24:50.837384+00:00 app[web.1]: [2013-09-25 07:24:50] INFO  WEBrick::HTTPServer#start: pid=2 port=10319
2013-09-25T07:24:51.052493+00:00 heroku[web.1]: State changed from starting to up
2013-09-25T07:25:03.254143+00:00 app[web.1]: => Run `rails server -h` for more startup options
2013-09-25T07:25:03.254143+00:00 app[web.1]: => Booting WEBrick
2013-09-25T07:25:03.254143+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-09-25T07:25:03.254143+00:00 app[web.1]: => Rails 4.0.0 application starting in production on http://0.0.0.0:10319
2013-09-25T07:25:03.254143+00:00 app[web.1]: Started GET "/" for 24.130.120.118 at 2013-09-25 07:25:03 +0000
2013-09-25T07:25:03.382939+00:00 heroku[router]: at=info method=GET path=/ host=secret-brook-8909.herokuapp.com fwd="24.130.120.118" dyno=web.1 connect=0ms service=137ms status=500 bytes=1266
2013-09-25T07:25:03.254143+00:00 app[web.1]: Started GET "/" for 24.130.120.118 at 2013-09-25 07:25:03 +0000
2013-09-25T07:25:03.386157+00:00 app[web.1]:                                   ^
2013-09-25T07:25:03.386157+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR:  relation "companies" does not exist
2013-09-25T07:25:03.386157+00:00 app[web.1]:     2:   <% @companies.each do |company| %>
2013-09-25T07:25:03.386354+00:00 app[web.1]: 
2013-09-25T07:25:03.386157+00:00 app[web.1]:     3:     <li>
2013-09-25T07:25:03.386354+00:00 app[web.1]: 
2013-09-25T07:25:03.386354+00:00 app[web.1]: 
2013-09-25T07:25:03.386157+00:00 app[web.1]:     5:         <%= image_tag company.image_url(:iphone) %>
2013-09-25T07:25:03.386354+00:00 app[web.1]:     1: <ul class="companies">
2013-09-25T07:25:03.386354+00:00 app[web.1]:   app/views/companies/index.html.erb:2:in `_app_views_companies_index_html_erb__1354484245348637346_70056053131700'
2013-09-25T07:25:03.386501+00:00 app[web.1]:     4:       <a href="<%= company_path(company) %>">
2013-09-25T07:25:03.386501+00:00 app[web.1]:     5:         <%= image_tag company.image_url(:iphone) %>
2013-09-25T07:25:03.386157+00:00 app[web.1]:     4:       <a href="<%= company_path(company) %>">
2013-09-25T07:25:03.386157+00:00 app[web.1]: 
2013-09-25T07:25:03.386354+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR:  relation "companies" does not exist
2013-09-25T07:25:03.386501+00:00 app[web.1]:   app/views/companies/index.html.erb:2:in `_app_views_companies_index_html_erb__1354484245348637346_70056053131700'
2013-09-25T07:25:03.386501+00:00 app[web.1]: 
2013-09-25T07:25:03.386501+00:00 app[web.1]: 
2013-09-25T07:25:03.386157+00:00 app[web.1]: LINE 1: SELECT "companies".* FROM "companies"
2013-09-25T07:25:03.386354+00:00 app[web.1]: LINE 1: SELECT "companies".* FROM "companies"
2013-09-25T07:25:03.386354+00:00 app[web.1]:                                   ^
2013-09-25T07:25:03.386354+00:00 app[web.1]: : SELECT "companies".* FROM "companies"):
2013-09-25T07:25:03.386157+00:00 app[web.1]:     1: <ul class="companies">
2013-09-25T07:25:03.386501+00:00 app[web.1]:     3:     <li>
2013-09-25T07:25:03.386157+00:00 app[web.1]: : SELECT "companies".* FROM "companies"):
2013-09-25T07:25:03.386354+00:00 app[web.1]:     2:   <% @companies.each do |company| %>
2013-09-25T07:25:03.577117+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=secret-brook-8909.herokuapp.com fwd="24.130.120.118" dyno=web.1 connect=0ms service=42ms status=200 bytes=0
2013-09-25T07:25:04.554698+00:00 app[web.1]: Started GET "/" for 24.130.120.118 at 2013-09-25 07:25:04 +0000
2013-09-25T07:25:04.562924+00:00 app[web.1]:     3:     <li>
2013-09-25T07:25:04.563111+00:00 app[web.1]: 
2013-09-25T07:25:04.562924+00:00 app[web.1]:     4:       <a href="<%= company_path(company) %>">
2013-09-25T07:25:04.563111+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR:  relation "companies" does not exist
2013-09-25T07:25:04.554698+00:00 app[web.1]: Started GET "/" for 24.130.120.118 at 2013-09-25 07:25:04 +0000
2013-09-25T07:25:04.562924+00:00 app[web.1]:     5:         <%= image_tag company.image_url(:iphone) %>
2013-09-25T07:25:04.563265+00:00 app[web.1]: 
2013-09-25T07:25:04.562924+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR:  relation "companies" does not exist
2013-09-25T07:25:04.563111+00:00 app[web.1]:   app/views/companies/index.html.erb:2:in `_app_views_companies_index_html_erb__1354484245348637346_70056053131700'
2013-09-25T07:25:04.563111+00:00 app[web.1]:     2:   <% @companies.each do |company| %>
2013-09-25T07:25:04.562924+00:00 app[web.1]:                                   ^
2013-09-25T07:25:04.563111+00:00 app[web.1]: 
2013-09-25T07:25:04.563265+00:00 app[web.1]:     3:     <li>
2013-09-25T07:25:04.562924+00:00 app[web.1]: 
2013-09-25T07:25:04.563111+00:00 app[web.1]: 
2013-09-25T07:25:04.563265+00:00 app[web.1]:     5:         <%= image_tag company.image_url(:iphone) %>
2013-09-25T07:25:04.562924+00:00 app[web.1]: LINE 1: SELECT "companies".* FROM "companies"
2013-09-25T07:25:04.563111+00:00 app[web.1]: LINE 1: SELECT "companies".* FROM "companies"
2013-09-25T07:25:04.563265+00:00 app[web.1]: 
2013-09-25T07:25:04.562924+00:00 app[web.1]: : SELECT "companies".* FROM "companies"):
2013-09-25T07:25:04.563111+00:00 app[web.1]:                                   ^
2013-09-25T07:25:04.562924+00:00 app[web.1]:     1: <ul class="companies">
2013-09-25T07:25:04.563111+00:00 app[web.1]: : SELECT "companies".* FROM "companies"):
2013-09-25T07:25:04.562924+00:00 app[web.1]:     2:   <% @companies.each do |company| %>
2013-09-25T07:25:04.563111+00:00 app[web.1]:     1: <ul class="companies">
2013-09-25T07:25:04.562453+00:00 heroku[router]: at=info method=GET path=/ host=secret-brook-8909.herokuapp.com fwd="24.130.120.118" dyno=web.1 connect=0ms service=13ms status=500 bytes=1266
2013-09-25T07:25:04.563265+00:00 app[web.1]:     4:       <a href="<%= company_path(company) %>">
2013-09-25T07:25:04.563265+00:00 app[web.1]:   app/views/companies/index.html.erb:2:in `_app_views_companies_index_html_erb__1354484245348637346_70056053131700'
2013-09-25T07:25:05.318117+00:00 app[web.1]: Started GET "/" for 24.130.120.118 at 2013-09-25 07:25:05 +0000
2013-09-25T07:25:05.318117+00:00 app[web.1]: Started GET "/" for 24.130.120.118 at 2013-09-25 07:25:05 +0000
2013-09-25T07:25:05.326126+00:00 app[web.1]: 
2013-09-25T07:25:05.326126+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR:  relation "companies" does not exist
2013-09-25T07:25:05.326126+00:00 app[web.1]:                                   ^
2013-09-25T07:25:05.326126+00:00 app[web.1]: LINE 1: SELECT "companies".* FROM "companies"
2013-09-25T07:25:05.326126+00:00 app[web.1]: : SELECT "companies".* FROM "companies"):
2013-09-25T07:25:05.326435+00:00 app[web.1]: 
2013-09-25T07:25:05.326278+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR:  relation "companies" does not exist
2013-09-25T07:25:05.326278+00:00 app[web.1]: LINE 1: SELECT "companies".* FROM "companies"
2013-09-25T07:25:05.326278+00:00 app[web.1]:                                   ^
2013-09-25T07:25:05.326278+00:00 app[web.1]: : SELECT "companies".* FROM "companies"):
2013-09-25T07:25:05.326126+00:00 app[web.1]:     1: <ul class="companies">
2013-09-25T07:25:05.326126+00:00 app[web.1]:     2:   <% @companies.each do |company| %>
2013-09-25T07:25:05.326126+00:00 app[web.1]:     3:     <li>
2013-09-25T07:25:05.326126+00:00 app[web.1]:     4:       <a href="<%= company_path(company) %>">
2013-09-25T07:25:05.326278+00:00 app[web.1]: 
2013-09-25T07:25:05.326126+00:00 app[web.1]:     5:         <%= image_tag company.image_url(:iphone) %>
2013-09-25T07:25:05.326278+00:00 app[web.1]:   app/views/companies/index.html.erb:2:in `_app_views_companies_index_html_erb__1354484245348637346_70056053131700'
2013-09-25T07:25:05.326278+00:00 app[web.1]: 
2013-09-25T07:25:05.326278+00:00 app[web.1]:     1: <ul class="companies">
2013-09-25T07:25:05.326278+00:00 app[web.1]:     2:   <% @companies.each do |company| %>
2013-09-25T07:25:05.326435+00:00 app[web.1]:     3:     <li>
2013-09-25T07:25:05.326278+00:00 app[web.1]: 
2013-09-25T07:25:05.326435+00:00 app[web.1]:     4:       <a href="<%= company_path(company) %>">
2013-09-25T07:25:05.326435+00:00 app[web.1]:     5:         <%= image_tag company.image_url(:iphone) %>
2013-09-25T07:25:05.326435+00:00 app[web.1]:   app/views/companies/index.html.erb:2:in `_app_views_companies_index_html_erb__1354484245348637346_70056053131700'
2013-09-25T07:25:05.326435+00:00 app[web.1]: 
2013-09-25T07:25:05.324465+00:00 heroku[router]: at=info method=GET path=/ host=secret-brook-8909.herokuapp.com fwd="24.130.120.118" dyno=web.1 connect=1ms service=11ms status=500 bytes=1266

我的宝石文件:

source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '4.0.0'
gem 'bootstrap-sass', '2.3.2.0'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.1.2'

gem 'rmagick'
gem 'carrierwave'

group :development, :test do
  gem 'sqlite3', '1.3.7'
  gem 'rspec-rails', '2.13.1'
  gem 'guard-rspec', '2.5.0'
end

group :test do
  gem 'selenium-webdriver', '2.0.0'
  gem 'capybara', '2.1.0'
  gem 'factory_girl_rails', '4.2.1'

  # Uncomment this line on OS X.
  # gem 'growl', '1.0.3'

  # Uncomment these lines on Linux.
  # gem 'libnotify', '0.8.0'

  # Uncomment these lines on Windows.
  # gem 'rb-notifu', '0.0.4'
  # gem 'win32console', '1.3.2'
end

gem 'sass-rails', '4.0.0'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.0'
gem 'jquery-rails', '2.2.1'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

group :production do
  gem 'pg', '0.15.1'
  gem 'rails_12factor', '0.0.2'
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

还在我的environment / production.rb文件中设置config.assets.compile = true。

我试图运行'heroku run rake',但它给了我错误:

运行rake附加到终端... up,ru

n.8382
rake aborted!
undefined method `[]' for nil:NilClass
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:136:in `purge'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:361:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:367:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/test_unit/testing.rake:61:in `block in <top (required)>'
Tasks: TOP => db:test:load => db:test:purge
(See full trace by running task with --trace)

提前致谢!

2 个答案:

答案 0 :(得分:1)

你需要做

heroku run rake db:migrate

答案 1 :(得分:0)

您的数据库似乎不存在或尚未创建。

尝试运行heroku run rake db:setup