やりたいこと
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と表示するようにする。
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def hello
render html:"hello, world!"
end
end
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
できた!!