herokuへRails4アプリをデプロイする際の注意点
Last-modified: Sat, 02 Aug 2014 09:03:16 JST (3517d)
Top > herokuへRails4アプリをデプロイする際の注意点
herokuへRails4アプリをデプロイする際の注意点
- Heroku Toolbeltをインストール
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
なお、http://toolbelt.heroku.com ./ Release.gpg
というエラーが出た場合は、FWとかプロクシとかアンチウイルスが原因らしいので、切ってみる。 - Herokuへログインする
heroku login
最終的にAuthentication successful.
と出ればOK。 - Gemfileに下記内容を追記し、bundle installする。
gem 'rails_12factor', :group => [:production]
- Herokuはsqliteが使えないので、postgresqlを使う。Gemfileに下記追記し、bundle installする。
gem 'pg', :group => [:production]
- database.ymlのproductionには以下のような感じで設定
production: adapter: postgresql encoding: utf8 database: <DB名> username: <ユーザ名> password: <パスワード> host: <接続先>
- なお、postgresqlの追加はHerokuのアプリケーションのadd-onsからheroku postgresをクリックして追加する。 追加したら、connectionsettingsの画面で設定内容が見れる。
- deviseを使っている場合は、production.rbに下記追記
config.action_mailer.default_url_options = { :host => 'self-ca.herokuapp.com' }
- production.rbより
config.assets.precompile
のコメントを外す。bundle exec rake assets:precompile
を実行。
herokuへデプロイするとCSSやJSが読み込まれない
Gemfileに
gem 'rails_12factor', :group => [:production]
を追記し、
bundle exec rake assets:precompile
でローカルの開発環境でプリコンパイルしたものをプッシュするとうまくいく。
http://stackoverflow.com/questions/10215416/javascript-features-work-on-localhost-but-not-when-deployed-to-heroku?lq=1
Counter: 380,
today: 2,
yesterday: 0
このページの参照回数は、380です。