LoginSignup
22
19

More than 5 years have passed since last update.

RailsのPJをherokuにデプロイする場合のハマりどころ

Posted at

引き続き、Rails初心者の私がはまったところのメモ。
ある程度ローカル環境で動くようになったのでherokuにデプロイしてみる

$ heroku login
$ git init
$ heroku git:remote -a {Project Name}
$ git add .
$ git commit -m "message"
$ git push heroku master

でやってみると

WARNING:
   You have not declared a Ruby version in your Gemfile.
   To set your Ruby version add this line to your Gemfile:
   ruby '2.0.0'
   # See https://devcenter.heroku.com/articles/ruby-versions for more information.
WARNING:
   No Procfile detected, using the default web server (webrick)
   https://devcenter.heroku.com/articles/ruby-default-web-server

Gemfileにrubyのバージョンを書いてなかった・・・
https://devcenter.heroku.com/articles/ruby-versions

Gemfileを修正して再度デプロイすると、エラーなく完了したので、ページにアクセスしてみると、

The page you were looking for doesn't exist.

今度はなに・・・

Herokuへのpushする場合に、productionならルートページを設定しないといけないらしい。
とりあえず、細かくは後で直すとして下記のようにroute.rbを修正して再度push。

root :to => 'some_controller#index'

some_controllerの部分は表示したいページのController、#以降はそのControllerのindex名。

ちなみに、
ローカルブランチの最新版をherokuにpushしようとするときに、

$ git push heroku master
Everything up-to-date

と怒られてしまって一向にpushできない場合は
開発ブランチ名を指定するといけるらしい。

例:開発ブランチ名が'dev'だった場合、

$ git push heroku dev:master
22
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
19