1 Install rails gem
#For rails6
gem install rails -v 6.0.1
#rails5.In case of 2
gem install rails -v 5.2.1
2 Postgresql installation
$ sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
$ wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install postgresql-common
$ sudo apt-get install postgresql-9.5 libpq-dev
3 Create a PostgreSQL Account
$ sudo -u postgres psql
postgres=# create role <username> with createdb login password '<password>';
postgres=# \q
4 Rails new
rails new appname -d postgresql
cd appname
5 Edit config / database.yml
default: &default
adapter: postgresql
encoding: unicode
pool: 5
#Below, 3 lines added
username: <username> #Same as the set PostgreSQL Account
password: <password> #Same as the set PostgreSQL Account
host: localhost
development:
<<: *default
database: appname_development #The appname should be the appname for rails new.
test:
<<: *default
database: appname_test #The appname should be the appname for rails new.
6 Create database with rails db: create & install webpacker
$ cd appname
$ rails db:create
#Not required for rails5
$ source <(curl -sL https://cdn.learnenough.com/yarn_install)
$ yarn install --check-files
$ rails webpacker:install
#config/enviroments/development.rb
config.hosts.clear
7 Heroku CLI Download and install
$ sudo curl https://cli-assets.heroku.com/install-ubuntu.sh | sh
$ heroku --version
8 Heroku login
$ heroku login
Email: [email protected]
Password: xxxxxxxx
9 Heroku Deploy Ready & Deploy
$ cd rails app
$ git init
$ git add -A
$ git commit -m "first"
#Deploy
$ heroku create
$ git push heroku master
$ heroku run rake db:migrate
--Application--Create heroku app with SSH settings 1 First, log in to Heroku.
$ heroku login --interactive
#You will be asked for your email address and password, so enter them and click enter
Enter your Heroku credentials:
Email: [email protected]
Password: *********
2 Next, add the key to Heroku.
$ heroku keys:add
3 Do you want to upload to Heroku? Is asked, so enter y
? Would you like to upload it to Heroku? (Y/n)
#Then, if the following code appears, it is successful.
Uploading /home/ec2-user/.ssh/id_rsa.pub SSH key... done
4 deploy
$ heroku create newsable-skillhub
#An app is created on Heroku.
Creating ⬢ newsable-skillhub... done
https://newsable-skillhub.herokuapp.com/ | https://git.heroku.com/newsable-skillhub.git
$ git init
$ git add -A
$ git commit -m "first"
$ git push heroku master
$ heroku run rake db:migrate
Recommended Posts