10
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

Organization

rails-tutorial 1章、herokuへのデプロイ作業に心を折られる

概要

https://railstutorial.jp/chapters/beginning?version=4.2
Railsのチュートリアルの「1.5 デプロイする」で嵌まりまくった。
以下解決までの手順をまとめます。

環境

ubuntu 16.04

$ ruby -v
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]

$ rails -v
rails 4.2.2

$ gem -v
2.5.1

解決までの手順

herokuにデプロイした後ブラウザで該当のページを開くと以下のようなエラー

Application Error

An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

エラーログを見る

ここからチュートリアルの内容から離れていきます

$ heroku run rails console
...
heroku rescue in spec': Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile
...

config/database.ymlの設定がsqlite3のままになっていたので修正

database.yml
production:
  <<: *default
  adapter: postgresql
  database: db/production.pg

再度アップロードするも別のエラー

We're sorry, but something went wrong.

herokuにPostgreSQLを導入し、データベースを作りなおす必要がありました。

$ heroku addons:create heroku-postgresql:hobby-dev
$ heroku run rake db:migrate
Running rake db:migrate on stormy-chamber-94768... up, run.2136 (Free)
   (15.1ms)  CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
   (12.8ms)  CREATE UNIQUE INDEX  "unique_schema_migrations" ON "schema_migration

hello, world

人類の勝利。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
10
Help us understand the problem. What are the problem?