0

我是 Rails 的初学者。我想在 heroku.com 上部署我的项目。我使用 Sqlite,但 heroku 不支持它。所以,我尝试将我的项目转移到 MySQL。我做了这个说明:Convert a Ruby on Rails app from sqlite to MySQL?

但是,heroku 是这样说的:我们很抱歉,但出了点问题。你能帮助我吗?

这是我的宝石文件:

source 'https://rubygems.org'

gem 'pg'
gem 'rails', '3.2.12'
gem 'gravatar_image_tag', '1.0.0.pre2'
gem "will_paginate", :git => "https://github.com/p7r/will_paginate.git", :branch => "rails3"
gem 'yaml_db', :git => 'git://github.com/ludicast/yaml_db.git'

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

group :development, :test do
  gem 'faker', '0.3.1'
  gem 'sqlite3-ruby', :require => 'sqlite3'
end

group :production do
    gem "mysql2", "~> 0.3.11"
end

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'


  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

group :test do
  gem 'rspec-rails', '2.6.1'
  gem 'webrat', '0.7.1'
end 

这是我的 database.yml 文件:

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: myapp_development
  pool: 5
  username: root
  password: "0761"
test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: myapp_test
  pool: 5
  username: root
  password: "0761"

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: myapp_production
  pool: 5
  username: root
  password: "0761"

这是我的日志:

2013-03-26T13:11:32+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-03-26T13:11:32+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-03-26T13:11:37+00:00 heroku[web.1]: Stopping remaining processes with SIGKILL
2013-03-26T13:11:37+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM
2013-03-26T13:11:38+00:00 app[web.1]: => Call with -d to detach
2013-03-26T13:11:38+00:00 app[web.1]: => Booting WEBrick
2013-03-26T13:11:38+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-03-26T13:11:38+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2013-03-26T13:11:38+00:00 app[web.1]: => Rails 3.2.12 application starting in production on http://0.0.0.0:33768
2013-03-26T13:11:39+00:00 app[web.1]: [2013-03-26 13:11:39] INFO  WEBrick::HTTPServer#start: pid=2 port=33768
2013-03-26T13:11:39+00:00 app[web.1]: [2013-03-26 13:11:39] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-03-26T13:11:39+00:00 app[web.1]: [2013-03-26 13:11:39] INFO  WEBrick 1.3.1
2013-03-26T13:11:39+00:00 heroku[web.1]: Process exited with status 137
2013-03-26T13:11:40+00:00 heroku[web.1]: State changed from starting to up
2013-03-26T13:11:59+00:00 app[web.1]: Started GET "/" for 46.72.99.61 at 2013-03-26 13:11:59 +0000
2013-03-26T13:11:59+00:00 app[web.1]: Processing by PagesController#home as HTML
2013-03-26T13:11:59+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (8.8ms)
2013-03-26T13:11:59+00:00 app[web.1]:   Rendered layouts/_stylesheets.html.erb (0.3ms)
2013-03-26T13:11:59+00:00 heroku[router]: at=info method=GET path=/ host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=0ms connect=3ms service=304ms status=500 bytes=643
2013-03-26T13:11:59+00:00 app[web.1]: Completed 500 Internal Server Error in 136ms
2013-03-26T13:11:59+00:00 app[web.1]: 
2013-03-26T13:11:59+00:00 app[web.1]:   Rendered layouts/_menu.html.erb (51.2ms)
2013-03-26T13:11:59+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR:  relation "users" does not exist
2013-03-26T13:11:59+00:00 app[web.1]: LINE 5:              WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:11:59+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-03-26T13:11:59+00:00 app[web.1]:                                         ^
2013-03-26T13:11:59+00:00 app[web.1]:     6:                <ul class="nav">
2013-03-26T13:11:59+00:00 app[web.1]:              WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:11:59+00:00 app[web.1]:              ORDER BY a.attnum
2013-03-26T13:11:59+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-03-26T13:11:59+00:00 app[web.1]:     8:                    <% if signed_in? %>
2013-03-26T13:11:59+00:00 app[web.1]:                AND a.attnum > 0 AND NOT a.attisdropped
2013-03-26T13:11:59+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-03-26T13:11:59+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-03-26T13:11:59+00:00 app[web.1]:     11:                   <li><%= link_to "Заказ", "#" %></li>
2013-03-26T13:11:59+00:00 app[web.1]:   app/models/user.rb:32:in `authenticate_with_salt'
2013-03-26T13:11:59+00:00 app[web.1]: ):
2013-03-26T13:11:59+00:00 app[web.1]:   app/helpers/sessions_helper.rb:13:in `current_user'
2013-03-26T13:11:59+00:00 app[web.1]:   app/helpers/sessions_helper.rb:17:in `signed_in?'
2013-03-26T13:11:59+00:00 app[web.1]:     9:                <!--<li><%= link_to "Users", users_path %></li>-->
2013-03-26T13:11:59+00:00 app[web.1]:   app/helpers/sessions_helper.rb:42:in `user_from_remember_token'
2013-03-26T13:11:59+00:00 app[web.1]:     7:                    <li class="active"><%= link_to "Главная", home_path %></li>
2013-03-26T13:11:59+00:00 app[web.1]:     5:            <div class="nav-collapse collapse">
2013-03-26T13:11:59+00:00 app[web.1]: 
2013-03-26T13:11:59+00:00 app[web.1]:   app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb__1283683624385357693_38228720'
2013-03-26T13:11:59+00:00 app[web.1]: 
2013-03-26T13:11:59+00:00 app[web.1]:     10:                   <li><%= link_to "Меню", menu_path %></li>
2013-03-26T13:11:59+00:00 app[web.1]:   app/views/layouts/_menu.html.erb:8:in `_app_views_layouts__menu_html_erb__3258341653661936969_33454780'
2013-03-26T13:12:00+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=16ms connect=35ms service=33ms status=200 bytes=0
2013-03-26T13:25:17+00:00 heroku[slugc]: Slug compilation started
2013-03-26T13:25:50+00:00 heroku[api]: Release v14 created by nikskalkin@gmail.com
2013-03-26T13:25:50+00:00 heroku[api]: Deploy 7a646d5 by nikskalkin@gmail.com
2013-03-26T13:25:50+00:00 heroku[web.1]: State changed from up to starting
2013-03-26T13:25:51+00:00 heroku[slugc]: Slug compilation finished
2013-03-26T13:25:51+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 59776`
2013-03-26T13:25:55+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-03-26T13:25:55+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-03-26T13:25:57+00:00 app[web.1]: => Booting WEBrick
2013-03-26T13:25:57+00:00 app[web.1]: => Call with -d to detach
2013-03-26T13:25:57+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2013-03-26T13:25:57+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-03-26T13:25:57+00:00 app[web.1]: => Rails 3.2.12 application starting in production on http://0.0.0.0:59776
2013-03-26T13:25:57+00:00 app[web.1]: [2013-03-26 13:25:57] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-03-26T13:25:57+00:00 app[web.1]: [2013-03-26 13:25:57] INFO  WEBrick::HTTPServer#start: pid=2 port=59776
2013-03-26T13:25:57+00:00 app[web.1]: [2013-03-26 13:25:57] INFO  WEBrick 1.3.1
2013-03-26T13:25:58+00:00 heroku[web.1]: State changed from starting to up
2013-03-26T13:25:59+00:00 app[web.1]: Started GET "/" for 46.72.99.61 at 2013-03-26 13:25:59 +0000
2013-03-26T13:26:00+00:00 app[web.1]: Processing by PagesController#home as HTML
2013-03-26T13:26:00+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (29.7ms)
2013-03-26T13:26:00+00:00 app[web.1]:   Rendered layouts/_stylesheets.html.erb (0.3ms)
2013-03-26T13:26:00+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR:  relation "users" does not exist
2013-03-26T13:26:00+00:00 app[web.1]: LINE 5:              WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:26:00+00:00 app[web.1]:                                         ^
2013-03-26T13:26:00+00:00 app[web.1]:   Rendered layouts/_menu.html.erb (26.4ms)
2013-03-26T13:26:00+00:00 app[web.1]:   app/helpers/sessions_helper.rb:42:in `user_from_remember_token'
2013-03-26T13:26:00+00:00 app[web.1]:   app/models/user.rb:32:in `authenticate_with_salt'
2013-03-26T13:26:00+00:00 app[web.1]:   app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb__3050356598751074094_29958360'
2013-03-26T13:26:00+00:00 app[web.1]: Completed 500 Internal Server Error in 99ms
2013-03-26T13:26:00+00:00 app[web.1]:     9:                <!--<li><%= link_to "Users", users_path %></li>-->
2013-03-26T13:26:00+00:00 app[web.1]:   app/views/layouts/_menu.html.erb:8:in `_app_views_layouts__menu_html_erb___3316497000915670487_28099760'
2013-03-26T13:26:00+00:00 app[web.1]:     6:                <ul class="nav">
2013-03-26T13:26:00+00:00 app[web.1]:     7:                    <li class="active"><%= link_to "Главная", home_path %></li>
2013-03-26T13:26:00+00:00 app[web.1]:   app/helpers/sessions_helper.rb:17:in `signed_in?'
2013-03-26T13:26:00+00:00 app[web.1]:              WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:26:00+00:00 app[web.1]: 
2013-03-26T13:26:00+00:00 app[web.1]:     5:            <div class="nav-collapse collapse">
2013-03-26T13:26:00+00:00 app[web.1]:     11:                   <li><%= link_to "Заказ", "#" %></li>
2013-03-26T13:26:00+00:00 app[web.1]: 
2013-03-26T13:26:00+00:00 app[web.1]: 
2013-03-26T13:26:00+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-03-26T13:26:00+00:00 app[web.1]:     10:                   <li><%= link_to "Меню", menu_path %></li>
2013-03-26T13:26:00+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-03-26T13:26:00+00:00 app[web.1]:     8:                    <% if signed_in? %>
2013-03-26T13:26:00+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-03-26T13:26:00+00:00 app[web.1]:                AND a.attnum > 0 AND NOT a.attisdropped
2013-03-26T13:26:00+00:00 app[web.1]:   app/helpers/sessions_helper.rb:13:in `current_user'
2013-03-26T13:26:00+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-03-26T13:26:00+00:00 app[web.1]:              ORDER BY a.attnum
2013-03-26T13:26:00+00:00 app[web.1]: ):
2013-03-26T13:26:00+00:00 heroku[router]: at=info method=GET path=/ host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=0ms connect=1ms service=254ms status=500 bytes=643
2013-03-26T13:26:00+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=0ms connect=3ms service=31ms status=200 bytes=0
root@Nikita-PC:/home/nikita/rails/invent# heroku open
Opening ancient-cliffs-5913... done
root@Nikita-PC:/home/nikita/rails/invent# heroku logs
2013-03-26T13:11:59+00:00 app[web.1]:     7:                    <li class="active"><%= link_to "Главная", home_path %></li>
2013-03-26T13:11:59+00:00 app[web.1]:     5:            <div class="nav-collapse collapse">
2013-03-26T13:11:59+00:00 app[web.1]: 
2013-03-26T13:11:59+00:00 app[web.1]:   app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb__1283683624385357693_38228720'
2013-03-26T13:11:59+00:00 app[web.1]: 
2013-03-26T13:11:59+00:00 app[web.1]:     10:                   <li><%= link_to "Меню", menu_path %></li>
2013-03-26T13:11:59+00:00 app[web.1]:   app/views/layouts/_menu.html.erb:8:in `_app_views_layouts__menu_html_erb__3258341653661936969_33454780'
2013-03-26T13:12:00+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=16ms connect=35ms service=33ms status=200 bytes=0
2013-03-26T13:25:17+00:00 heroku[slugc]: Slug compilation started
2013-03-26T13:25:50+00:00 heroku[api]: Release v14 created by nikskalkin@gmail.com
2013-03-26T13:25:50+00:00 heroku[api]: Deploy 7a646d5 by nikskalkin@gmail.com
2013-03-26T13:25:50+00:00 heroku[web.1]: State changed from up to starting
2013-03-26T13:25:51+00:00 heroku[slugc]: Slug compilation finished
2013-03-26T13:25:51+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 59776`
2013-03-26T13:25:55+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-03-26T13:25:55+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-03-26T13:25:57+00:00 app[web.1]: => Booting WEBrick
2013-03-26T13:25:57+00:00 app[web.1]: => Call with -d to detach
2013-03-26T13:25:57+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2013-03-26T13:25:57+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-03-26T13:25:57+00:00 app[web.1]: => Rails 3.2.12 application starting in production on http://0.0.0.0:59776
2013-03-26T13:25:57+00:00 app[web.1]: [2013-03-26 13:25:57] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-03-26T13:25:57+00:00 app[web.1]: [2013-03-26 13:25:57] INFO  WEBrick::HTTPServer#start: pid=2 port=59776
2013-03-26T13:25:57+00:00 app[web.1]: [2013-03-26 13:25:57] INFO  WEBrick 1.3.1
2013-03-26T13:25:58+00:00 heroku[web.1]: State changed from starting to up
2013-03-26T13:25:59+00:00 app[web.1]: Started GET "/" for 46.72.99.61 at 2013-03-26 13:25:59 +0000
2013-03-26T13:26:00+00:00 app[web.1]: Processing by PagesController#home as HTML
2013-03-26T13:26:00+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (29.7ms)
2013-03-26T13:26:00+00:00 app[web.1]:   Rendered layouts/_stylesheets.html.erb (0.3ms)
2013-03-26T13:26:00+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR:  relation "users" does not exist
2013-03-26T13:26:00+00:00 app[web.1]: LINE 5:              WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:26:00+00:00 app[web.1]:                                         ^
2013-03-26T13:26:00+00:00 app[web.1]:   Rendered layouts/_menu.html.erb (26.4ms)
2013-03-26T13:26:00+00:00 app[web.1]:   app/helpers/sessions_helper.rb:42:in `user_from_remember_token'
2013-03-26T13:26:00+00:00 app[web.1]:   app/models/user.rb:32:in `authenticate_with_salt'
2013-03-26T13:26:00+00:00 app[web.1]:   app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb__3050356598751074094_29958360'
2013-03-26T13:26:00+00:00 app[web.1]: Completed 500 Internal Server Error in 99ms
2013-03-26T13:26:00+00:00 app[web.1]:     9:                <!--<li><%= link_to "Users", users_path %></li>-->
2013-03-26T13:26:00+00:00 app[web.1]:   app/views/layouts/_menu.html.erb:8:in `_app_views_layouts__menu_html_erb___3316497000915670487_28099760'
2013-03-26T13:26:00+00:00 app[web.1]:     6:                <ul class="nav">
2013-03-26T13:26:00+00:00 app[web.1]:     7:                    <li class="active"><%= link_to "Главная", home_path %></li>
2013-03-26T13:26:00+00:00 app[web.1]:   app/helpers/sessions_helper.rb:17:in `signed_in?'
2013-03-26T13:26:00+00:00 app[web.1]:              WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:26:00+00:00 app[web.1]: 
2013-03-26T13:26:00+00:00 app[web.1]:     5:            <div class="nav-collapse collapse">
2013-03-26T13:26:00+00:00 app[web.1]:     11:                   <li><%= link_to "Заказ", "#" %></li>
2013-03-26T13:26:00+00:00 app[web.1]: 
2013-03-26T13:26:00+00:00 app[web.1]: 
2013-03-26T13:26:00+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-03-26T13:26:00+00:00 app[web.1]:     10:                   <li><%= link_to "Меню", menu_path %></li>
2013-03-26T13:26:00+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-03-26T13:26:00+00:00 app[web.1]:     8:                    <% if signed_in? %>
2013-03-26T13:26:00+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-03-26T13:26:00+00:00 app[web.1]:                AND a.attnum > 0 AND NOT a.attisdropped
2013-03-26T13:26:00+00:00 app[web.1]:   app/helpers/sessions_helper.rb:13:in `current_user'
2013-03-26T13:26:00+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-03-26T13:26:00+00:00 app[web.1]:              ORDER BY a.attnum
2013-03-26T13:26:00+00:00 app[web.1]: ):
2013-03-26T13:26:00+00:00 heroku[router]: at=info method=GET path=/ host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=0ms connect=1ms service=254ms status=500 bytes=643
2013-03-26T13:26:00+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=0ms connect=3ms service=31ms status=200 bytes=0
2013-03-26T13:25:53+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2013-03-26T13:25:54+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/server.rb:90:in `select'
2013-03-26T13:25:54+00:00 app[web.1]: [2013-03-26 13:25:54] ERROR SignalException: SIGTERM
2013-03-26T13:26:04+00:00 heroku[web.1]: Stopping remaining processes with SIGKILL
2013-03-26T13:26:04+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM
2013-03-26T13:26:06+00:00 heroku[web.1]: Process exited with status 137
2013-03-26T13:29:30+00:00 app[web.1]: Started GET "/" for 46.72.99.61 at 2013-03-26 13:29:30 +0000
2013-03-26T13:29:30+00:00 app[web.1]:   Rendered layouts/_stylesheets.html.erb (0.0ms)
2013-03-26T13:29:30+00:00 app[web.1]: Processing by PagesController#home as HTML
2013-03-26T13:29:30+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (0.0ms)
2013-03-26T13:29:30+00:00 app[web.1]: LINE 5:              WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:29:30+00:00 app[web.1]:                                         ^
2013-03-26T13:29:30+00:00 app[web.1]:   Rendered layouts/_menu.html.erb (6.5ms)
2013-03-26T13:29:30+00:00 app[web.1]: Completed 500 Internal Server Error in 13ms
2013-03-26T13:29:30+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR:  relation "users" does not exist
2013-03-26T13:29:30+00:00 app[web.1]: 
2013-03-26T13:29:30+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-03-26T13:29:30+00:00 app[web.1]:              WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:29:30+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-03-26T13:29:30+00:00 app[web.1]:                AND a.attnum > 0 AND NOT a.attisdropped
2013-03-26T13:29:30+00:00 app[web.1]:              ORDER BY a.attnum
2013-03-26T13:29:30+00:00 app[web.1]: ):
2013-03-26T13:29:30+00:00 app[web.1]:     6:                <ul class="nav">
2013-03-26T13:29:30+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-03-26T13:29:30+00:00 app[web.1]:     5:            <div class="nav-collapse collapse">
2013-03-26T13:29:30+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-03-26T13:29:30+00:00 app[web.1]:     10:                   <li><%= link_to "Меню", menu_path %></li>
2013-03-26T13:29:30+00:00 app[web.1]:     9:                <!--<li><%= link_to "Users", users_path %></li>-->
2013-03-26T13:29:30+00:00 app[web.1]:     11:                   <li><%= link_to "Заказ", "#" %></li>
2013-03-26T13:29:30+00:00 app[web.1]:   app/models/user.rb:32:in `authenticate_with_salt'
2013-03-26T13:29:30+00:00 app[web.1]:   app/helpers/sessions_helper.rb:13:in `current_user'
2013-03-26T13:29:30+00:00 app[web.1]:   app/helpers/sessions_helper.rb:17:in `signed_in?'
2013-03-26T13:29:30+00:00 app[web.1]:     8:                    <% if signed_in? %>
2013-03-26T13:29:30+00:00 app[web.1]:   app/helpers/sessions_helper.rb:42:in `user_from_remember_token'
2013-03-26T13:29:30+00:00 app[web.1]:     7:                    <li class="active"><%= link_to "Главная", home_path %></li>
2013-03-26T13:29:30+00:00 app[web.1]: 
2013-03-26T13:29:30+00:00 app[web.1]: 
2013-03-26T13:29:30+00:00 app[web.1]:   app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb__3050356598751074094_29958360'
2013-03-26T13:29:30+00:00 app[web.1]:   app/views/layouts/_menu.html.erb:8:in `_app_views_layouts__menu_html_erb___3316497000915670487_28099760'
2013-03-26T13:29:30+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 connect=10ms service=9ms status=304 bytes=0
2013-03-26T13:29:30+00:00 heroku[router]: at=info method=GET path=/ host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=0ms connect=1ms service=34ms status=500 bytes=643

更新 我只能使用 MySQL。我的项目是测试我正在寻找的一家公司的实习任务。他们说我在项目中使用 MySql。

4

5 回答 5

4

Heroku 真正设计为运行 PostgreSQL 作为其数据库引擎,而不是 MySQL。您实际上已经安装了 postgresql gem ( pg)。您收到的错误与访问数据库(特别是users表)有关。

虽然可以作为新用户在 Heroku 上运行 MySQL,但我建议只使用 postgresql,因为它更容易设置,您不必担心安装额外的附加组件来使其工作。

于 2013-03-26T13:41:05.537 回答
1

你在哪里托管你的 MySQL 数据库? 确保您的数据库服务器允许从 Heroku 进行远程访问。正确设置后,亚马逊 (AWS) 是最佳解决方案。

如果您在本地计算机上托管 MySQL 数据库以进行生产,那么您需要确保 Heroku 的服务器可以远程访问您的计算机以进行生产

在您的 Gemfile 中删除这些行并替换为下面的示例。

  • gem 'pg'
  • gem 'sqlite3-ruby', :require => 'sqlite3'
  • gem "mysql2", "~> 0.3.11"

我也强烈建议查看https://github.com/laserlemon/figarohttp://railscasts.com/episodes/85-yaml-configuration-revised?view=comments

在 AWS 上设置 MySQL:

  1. 使用正确的数据库 gem 更新 Gemfile
  2. 更新 database.yml 连接设置
  3. 安装 Heroku 工具带https://toolbelt.heroku.com/
  4. 注册 AWS 托管的 MySQL http://aws.amazon.com/rds/
  5. Amazon 要求您从本地计算机的 WAN IP 授予访问权限,并且您还需要授予 Heroku 的应用程序服务器授权访问权限以进行生产。
    • 通过以下方式登录 AWShttp://console.aws.amazon.com/
    • 转到“服务”>“RDS”
    • 在左侧菜单“导航/数据库”>“数据库安全组”>“默认”下
    • 添加 CIDR/IP:#.#.#.#(您的本地 pc ip http://www.whatsmyip.us/
    • 添加 EC2 安全组(这是 heroku aws id)
      • aws 帐户 ID:“098166147350”
      • ec2 安全组:“默认”
  6. 在 Heroku 上设置 AWS RDS MySQL 数据库
    • 确认 Heroku 被授予 AWS RDS 远程访问权限
      • $ cd myAppDir
      • $ heroku login
      • $ heroku config:get DATABASE_URL
      • $ heroku addons:add amazon_rds url=mysql2://masteruser:pass@dbinstance.123endpoint321.amazonaws.com/databasename
      • $ heroku config:get DATABASE_URL
      • 确认新的数据库设置

Gemfile ~ 不要忘记$ bundle install&$ bundle update

# ===~===~===~===~===~===~===~===~===~===
group :development do
  gem 'mysql2'
end
# ===~===~===~===~===~===~===~===~===~===
group :production do
  # gem 'pg'
  gem 'mysql2'
end
# ===~===~===~===~===~===~===~===~===~===
group :test do
  gem 'sqlite3'
  # gem 'mysql2'
end
# ===~===~===~===~===~===~===~===~===~===

database.yml ~ 每种类型的 db 连接的示例。

# AWS RDS ~~~~~~~~~~~~~~~~
development:
  adapter: mysql2
  encoding: utf8
  host: dbinstance.123endpoint789.us-east-1.rds.amazonaws.com
  database: appdb_dev
  pool: 5
  username: masterusername
  password: password
  socket: /tmp/mysql.sock
# ~~~~~~~~~~~~~~~~~~~~~~~~
# MySQL localhost ~~~~~~~~
# development:
#   adapter: mysql2
#   encoding: utf8
#   database: erics_rails_app_dev
#   pool: 5
#   username: root
#   password:
#   socket: /tmp/mysql.sock
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# HEROKU ~~~~~~~~~~~~~~~~~
# Note: On Heroku production this (over)written on deployment.
production:
  adapter: pg
  database: localhost
  timeout: 5000
# ORIGINAL TEST ~~~~~~~~~~~~~~~
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

MySQL 工作台设置 ~ http://dev.mysql.com/downloads/workbench/

* hostname = dbinstance.123endpoint789.us-east-1.rds.amazonaws.com
* user = masterusername
* pass = password
* port = 3306
于 2013-03-26T14:52:42.640 回答
0

你有这个应用程序的 mysql 插件吗?

Heroku 默认为您提供 Postgres 数据库,但如果您想使用另一种数据库类型,即 mysql,则需要使用插件。我不确定插件中可能有免费的解决方案。

当您将应用程序部署到 Heroku 时,它们会覆盖您的 database.yml 文件,将其指向正确的数据库 url。

于 2013-03-26T13:41:11.380 回答
0

首先 heroku 为您的应用程序提供 PostgreSQL 数据库,编辑您的 Gemfile

并添加 gem 'pg'

它也使用瘦作为服务器,所以添加

宝石“薄”

将您的 Database.yml 更改为所有环境

adapter: PostgreSQL
  encoding: utf8
  reconnect: false
  database: myapp_production
  pool: 5
  username: root
  password: "0761"
于 2013-03-26T13:42:21.380 回答
0

从生产环境中删除 mysql gem。Heroku 不支持 sqlite 数据库。在生产中使用 postgres。您的 gemfile 应如下所示:

group :production do
  gem "pg" # move your pg gem inside here
end

group :development, :test do
  gem "sqlite3"
end

更改您的 gemfile 以反映上述内容,$ bundle然后运行捆绑新的 gem,添加并提交您的更改并将它们推送到 heroku。

这将允许您在开发和测试中使用 sqlite,在生产中使用 postgresql,这是 heroku 所需要的。

于 2013-03-26T13:50:15.213 回答