Please point out any corrections for beginners in programming. It is assumed that you have git installed.
Heroku is a cloud platform that makes it easy to publish web applications to the world.
Reference) What is HEROKU?
Register as a Heroku user from the URL below. User registration is free.
By installing The Heroku CLI, you can use Heroku commands.
Please specify the OS from the link below and download it to complete the installation.
Now that you have the Heroku CLI installed, you can use Heroku commands on your terminal.
Let's log in to Heroku from the terminal immediately.
Go to the directory of the app you want to upload to Heroku and run the "heroku login command".
After executing the login command, you will need to enter the email address and password you registered with heroku.
Make the $ cd app # app part the name of the app you created
$ heroku login #Log in to heroku
Enter your Heroku credentials:
When you have entered your e-mail address and password, the following will be displayed.
Logged in as the email address you entered
# 3.Deploy to Heroku Heroku uses a PostgreSQL database. So, I will install PostgreSQL. Execute the following command in the terminal. (If you have already installed it, you do not need to install it.)
$ brew install postgresql
Once the installation is complete, production(production)Install pg gem in your environment to allow Rails to communicate with PostgreSQL. Add the following code to the bottom of the Gemfile. #### **`Gemfile.`**
group :production do gem 'pg' end
The pg gem is a production gem and should not be installed locally. In that case, bundle install--Add without production. By adding this flag, the pg gem will not be reflected in the local environment. Now execute the following command.
$ bundle install --without production
For production environment of bundle install Then use the "heroku create app name" command to create an application on heroku. Execute the following command.
$ heroku create
If you do not enter the application name as described above, it will be named automatically. ***Please note that the name once registered cannot be used.*** When I run the above command, I get the following result:
Creating app ... done, ⬢ app (app name) https://app (app name) .herokuapp.com / | https://git.heroku.com/app (app name) .git
https://~~.herokuapp.com/Is the subdomain created by the above command. You can see it in your browser at this point, but there is nothing yet. Let's deploy and display the web page. To deploy your Rails application to Heroku, first use Git to push the repository to Heroku.
$ git add . $ git commit -m "initial commit" $ git push heroku master
If it goes well, remote as below: Verifying deploy... done.It will be displayed.
. . . remote: Verifying deploy... done. To https://git.heroku.com/app (app name) .git
Next, execute migration with the following command. Rails db that was done in the local environment:The image is that the migrate command is also executed in the production environment.
$ heroku run rails db:migrate
After executing the above command, execute the following command to display the web page.
$ heroku open
that's all. ###Reference article https://qiita.com/kazukimatsumoto/items/a0daa7281a3948701c39 https://qiita.com/NaokiIshimura/items/eee473675d624a17310f