2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails × Herokuで出来ること

Last updated at Posted at 2015-08-02

Railstutrialで登場するHeroku関連のメモ
随時更新

Herokuの導入

アカウントを取得する

Heroku

Heroku Toolbeltをインストールする

$ sudo yum install wget
$ wget -O- https://toolbelt.heroku.com/install.sh | sh
$ echo 'PATH="/usr/local/heroku/bin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile

Gemfileのproductionグループにpostgressを設定する

gemfile
group :production do
    gem 'pg'
end

$ bundle install --without production

herokuにログインする

$ heroku login

リモートリポジトリを登録する

git remote add heroku git@heroku.com:{my-project-name}.git
{my-project-name}はherokuのSettingsで確認できる

SSHキーを登録する

heroku keys:add
(キーを削除する場合)
 heroku keys:clear

プッシュする

$ git push heroku master

Heroku側でマイグレーションを実行する

$ heroku run rake db:migrate

TIPS

HerokuのAppの名前を変更する

$ heroku rename {任意の名前}
ダッシュボードから変更するとおそらく各種設定の整合性が壊れる

herokuにサンプルデータを投入する

$ heroku pg:reset DATABASE
$ heroku run rake db:migrate
$ heroku run rake db:populate

SSLを有効にする

管理者画面だけでもSSLを導入したい場合、SSL付きのHerokuドメインが使えるのは便利

config/environments/production.rb
SampleApp::Application.configure do
  .
  .
  .
  # Force all access to the app over SSL, use Strict-Transport-Security,
  # and use secure cookies.
  config.force_ssl = true
  .
  .
  .
end

ログを見る

$ heroku logs

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?