将应用程序部署到 Heroku 时出错:Railsbridge Installfest—部署 Rails 应用程序

Error When Deploying App to Heroku: Railsbridge Installfest—Deploy a Rails App

我正在执行 railsbridge installfest(作为 Odin 项目的一部分),我 运行 在最后阶段遇到了问题:"Deploy A Rails App." 我得到了很多来自终端的意外结果,当我在教程结束时导航到 heroku 应用程序的网址时,我得到:

"您要查找的页面不存在。 您可能输入了错误的地址或页面可能已移动。 如果您是应用程序所有者,请查看日志以获取更多信息。"

我正在 运行ning Ubuntu 16.04 LTS 作为 Windows 10 上的虚拟机。我尝试删除教程中创建的 test_app(均在线)和关闭)并重新开始,我尝试在重新开始之前关闭和打开 VM,但没有成功。我也在这个网站上寻找过有类似问题的人,但找不到任何等效的错误消息。

在出现这些问题之前,教程让我创建了一个 rails 服务器,它的功能与我被告知的完全一样。问题仅在我尝试将应用程序部署到 heroku 时出现。

我已经包括了我经历的所有阶段。在预期的命令行结果(如教程中指定的)与我的实际结果不同的地方,我将两者都包括在内,并标记为差异。我没有包括预期的命令行结果——这个问题已经足够长了,我不添加所有这些!如果您需要该信息来帮助我,我已将其保存,请告诉我。

如果我遗漏了一些明显的东西,我深表歉意——我完全编码新手。

我执行了(在终端):

git init
git add -A
git commit -m "initial commit"
git log
heroku create

第一个差异:

预期代码:

Enter your Heroku credentials.
Email: myemail@example.com
Password:
Uploading ssh public key /Users/smei/.ssh/id_rsa.pub
Creating floating-winter-18... done, stack is cedar
http://floating-winter-18.heroku.com/ | git@heroku.com:floating-winter-18.git
Git remote heroku added

实际代码:

Creating app... done, ⬢ tranquil-beyond-97147
https://tranquil-beyond-97147.herokuapp.com/ | https://git.heroku.com/tranquil-beyond-97147.git

然后我在 ~/railsbridge/test_app/Gemfile 中从

更改了一行
gem 'sqlite3'

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

group :production do
  gem 'pg'
end

然后(再次在终端中)我执行了:

gem install bundler
bundle install --without production

然后我在 ~/railsbridge/test_app/config/routes.rb 行 Rails.application.routes.draw do:

下添加了一行

添加的行:

root 'drinks#index'

然后(回到终端)我执行了:

git add .
git commit -m "Updates for heroku deployment"
git push heroku master

第二个差异:

预期代码:

The authenticity of host 'heroku.com (75.101.145.87)' can't be established.
RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'heroku.com,75.101.145.87' (RSA) to the list of known hosts.
Counting objects: 60, done.
Compressing objects: 100% (54/54), done.
Writing objects: 100% (60/60), 79.03 KiB, done.
Total 60 (delta 10), reused 0 (delta 0)

-----> Heroku receiving push
-----> Rails app detected
       Compiled slug size is 080K
-----> Launching...... done
       App deployed to Heroku

To git@heroku.com:floating-winter-18.git
 * [new branch]      master -> master

实际代码:

Counting objects: 114, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (100/100), done.
Writing objects: 100% (114/114), 25.05 KiB | 0 bytes/s, done.
Total 114 (delta 7), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.2.4
remote: -----> Installing dependencies using bundler 1.11.2
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
remote:        Fetching gem metadata from https://rubygems.org/..........
remote:        Fetching version metadata from https://rubygems.org/...
remote:        Fetching dependency metadata from https://rubygems.org/..
remote:        Installing i18n 0.7.0
remote:        Installing concurrent-ruby 1.0.2
remote:        Installing rake 11.3.0
remote:        Installing minitest 5.9.1
remote:        Installing builder 3.2.2
remote:        Installing thread_safe 0.3.5
remote:        Installing mini_portile2 2.1.0
remote:        Installing erubis 2.7.0
remote:        Installing rack 2.0.1
remote:        Installing nio4r 1.2.1 with native extensions
remote:        Installing websocket-extensions 0.1.2
remote:        Installing mime-types-data 3.2016.0521
remote:        Installing arel 7.1.4
remote:        Installing coffee-script-source 1.10.0
remote:        Installing execjs 2.7.0
remote:        Installing thor 0.19.1
remote:        Installing multi_json 1.12.1
remote:        Installing pg 0.19.0 with native extensions
remote:        Installing method_source 0.8.2
remote:        Installing puma 3.6.0 with native extensions
remote:        Using bundler 1.11.2
remote:        Installing sass 3.4.22
remote:        Installing tilt 2.0.5
remote:        Installing turbolinks-source 5.0.0
remote:        Installing nokogiri 1.6.8.1 with native extensions
remote:        Installing tzinfo 1.2.2
remote:        Installing websocket-driver 0.6.4 with native extensions
remote:        Installing rack-test 0.6.3
remote:        Installing sprockets 3.7.0
remote:        Installing mime-types 3.1
remote:        Installing coffee-script 2.4.1
remote:        Installing uglifier 3.0.2
remote:        Installing turbolinks 5.0.1
remote:        Installing activesupport 5.0.0.1
remote:        Installing mail 2.6.4
remote:        Installing globalid 0.3.7
remote:        Installing activemodel 5.0.0.1
remote:        Installing jbuilder 2.6.0
remote:        Installing activejob 5.0.0.1
remote:        Installing activerecord 5.0.0.1
remote:        Installing loofah 2.0.3
remote:        Installing rails-html-sanitizer 1.0.3
remote:        Installing rails-dom-testing 2.0.1
remote:        Installing actionview 5.0.0.1
remote:        Installing actionpack 5.0.0.1
remote:        Installing actionmailer 5.0.0.1
remote:        Installing actioncable 5.0.0.1
remote:        Installing railties 5.0.0.1
remote:        Installing sprockets-rails 3.2.0
remote:        Installing coffee-rails 4.2.1
remote:        Installing rails 5.0.0.1
remote:        Installing jquery-rails 4.2.1
remote:        Installing sass-rails 5.0.6
remote:        Bundle complete! 16 Gemfile dependencies, 53 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into ./vendor/bundle.
remote:        Bundle completed (25.91s)
remote:        Cleaning up the bundler cache.
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        I, [2016-10-16T22:14:51.182054 #1022]  INFO -- : Writing /tmp/build_eaa9178115288d749f254409ffd66e9f/public/assets/application-ea005870b2299ed0464e134ab4079aa8856885e9ffd3d81e60417322f2fa0a97.js
remote:        I, [2016-10-16T22:14:51.202261 #1022]  INFO -- : Writing /tmp/build_eaa9178115288d749f254409ffd66e9f/public/assets/application-ea005870b2299ed0464e134ab4079aa8856885e9ffd3d81e60417322f2fa0a97.js.gz
remote:        I, [2016-10-16T22:14:51.252933 #1022]  INFO -- : Writing /tmp/build_eaa9178115288d749f254409ffd66e9f/public/assets/application-d12397cbc3a266ce5a99f7b588223090c55ca04a439953bb5f9304395de93fc3.css
remote:        I, [2016-10-16T22:14:51.253116 #1022]  INFO -- : Writing /tmp/build_eaa9178115288d749f254409ffd66e9f/public/assets/application-d12397cbc3a266ce5a99f7b588223090c55ca04a439953bb5f9304395de93fc3.css.gz
remote:        Asset precompilation completed (3.83s)
remote:        Cleaning assets
remote:        Running: rake assets:clean
remote: 
remote: ###### WARNING:
remote:        You have not declared a Ruby version in your Gemfile.
remote:        To set your Ruby version add this line to your Gemfile:
remote:        ruby '2.2.4'
remote:        # See https://devcenter.heroku.com/articles/ruby-versions for more information.
remote: 
remote: ###### WARNING:
remote:        No Procfile detected, using the default web server.
remote:        We recommend explicitly declaring how to boot your server process via a Procfile.
remote:        https://devcenter.heroku.com/articles/ruby-default-web-server
remote: 
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> console, rake, web, worker
remote: 
remote: -----> Compressing...
remote:        Done: 27.9M
remote: -----> Launching...
remote:        Released v5
remote:        https://tranquil-beyond-97147.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/tranquil-beyond-97147.git
 * [new branch]      master -> master

最后,我进入了

heroku run rake db:migrate

第三个差异:

预期代码:

Migrating to CreateDrinks (20160706063236)
==  20160706063236 CreateDrinks: migrating =====================================
-- create_table(:drinks)
   -> 0.0084s
==  20160706063236 CreateDrinks: migrated (0.0085s) ============================

实际代码:

Running rake db:migrate on ⬢ tranquil-beyond-97147... up, run.1313 (Free)
D, [2016-10-16T22:16:19.568857 #3] DEBUG -- :    (12.1ms)  CREATE TABLE "schema_migrations" ("version" character varying PRIMARY KEY)
D, [2016-10-16T22:16:19.582446 #3] DEBUG -- :    (7.5ms)  CREATE TABLE "ar_internal_metadata" ("key" character varying PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
D, [2016-10-16T22:16:19.586398 #3] DEBUG -- :    (1.8ms)  SELECT pg_try_advisory_lock(4170385879066863015);
D, [2016-10-16T22:16:19.598567 #3] DEBUG -- :   ActiveRecord::SchemaMigration Load (1.9ms)  SELECT "schema_migrations".* FROM "schema_migrations"
I, [2016-10-16T22:16:19.604863 #3]  INFO -- : Migrating to CreateDrinks (20161016221052)
D, [2016-10-16T22:16:19.607807 #3] DEBUG -- :    (1.8ms)  BEGIN
== 20161016221052 CreateDrinks: migrating =====================================
-- create_table(:drinks)
D, [2016-10-16T22:16:19.615754 #3] DEBUG -- :    (7.0ms)  CREATE TABLE "drinks" ("id" serial primary key, "name" character varying, "temperature" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
   -> 0.0078s
== 20161016221052 CreateDrinks: migrated (0.0079s) ============================

D, [2016-10-16T22:16:19.623202 #3] DEBUG -- :   SQL (1.9ms)  INSERT INTO "schema_migrations" ("version") VALUES () RETURNING "version"  [["version", "20161016221052"]]
D, [2016-10-16T22:16:19.627228 #3] DEBUG -- :    (3.8ms)  COMMIT
D, [2016-10-16T22:16:19.637096 #3] DEBUG -- :   ActiveRecord::InternalMetadata Load (1.8ms)  SELECT  "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" =  LIMIT   [["key", :environment], ["LIMIT", 1]]
D, [2016-10-16T22:16:19.644393 #3] DEBUG -- :    (1.6ms)  BEGIN
D, [2016-10-16T22:16:19.647314 #3] DEBUG -- :   SQL (1.9ms)  INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (, , , ) RETURNING "key"  [["key", "environment"], ["value", "production"], ["created_at", 2016-10-16 22:16:19 UTC], ["updated_at", 2016-10-16 22:16:19 UTC]]
D, [2016-10-16T22:16:19.649903 #3] DEBUG -- :    (2.4ms)  COMMIT
D, [2016-10-16T22:16:19.651778 #3] DEBUG -- :    (1.7ms)  SELECT pg_advisory_unlock(4170385879066863015)

我希望我已经尽可能清楚地说明了这一点,在此先感谢您提供的任何帮助。

我会说你应该检查 tranquil-beyond-97147.herokuapp.com,因为这是 Heroku 为你创建的应用程序的名称。 如果没有通过,你应该 运行 heroku logs 并粘贴内容,错误的原因总是在日志中。