LoginSignup
0

More than 3 years have passed since last update.

【Rails+PostgreSQL+Heroku】環境構築まとめ

Last updated at Posted at 2019-12-21

やりたいこと

rails new で作ったアプリをheorkuでデプロイしたい。
herokuではsqliteではなくpostgresqlを使わないとダメなので、初めからその設定をしておく。
psql 12.1
Rails 5.0.7.2

railsの設定

rails new e-stat-rails --database=postgresql
rails db:create
rails db:migrate
rails server
localhost:3000で起動できているか確認。

エラー対処

【再起動して解決】connections on Unix domain socket “/tmp/.s.PGSQL.5432”?への対処

【rails】Specified 'postgresql' for database adapter, but the gem is not loaded と怒られた件

herokuへ

Herokuへデプロイした時に「The page you were looking for doesn't exist. 」エラーが出る
こうならないようにcontrollerとroutesを設定してrootでhelloworldと表示するようにする。

application_controller.rb

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception

  def hello
    render html:"hello, world!"
  end
end
routes.rb

Rails.application.routes.draw do
  root 'application#hello'
end

git add .
git commit -m "hogehoge"
git push origin master
heroku create
git push heroku
heroku open

できた!!

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
0