I was trying to deploy the Rails 6.0 app to Heroku with the developer guidelines in Heroku itself. But I faced a lot of problems in Heroku not being deployed properly. If anyone is facing the same problem, this might help you in solving them!!
Let’s discuss how I solved them!!
First, log in to Heroku
heroku login
Create a Heroku app with default buildpacks ruby.
heroku create <app-name> --buildpacks heroku/ruby
Add buildpacks for node.
heroku buildpacks:add heroku/nodejs
Create a Procfile
web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}
Add database addons. In my case, I was using PostgreSQL.
heroku addons:create heroku-postgresql:hobby-dev
Now that the application is set up, you can push your code to the Heroku server. Make sure that your webpacker.yml is pushed to the server.
git push heroku main || git push heroku master
If you want to deploy a branch other than master, you can push it like below:
git push heroku <branch_name>:master
Run database migration
heroku run rake db:migrate
Checking dyno
heroku ps:scale web=1
Check your Heroku app logs
heroku logs --tail
Launch rails console
heroku run rails console
For the Rails assets pipeline, you will need to enable this in your environment file. Make sure that your assets are required without extensions.
config.public_file_server.enabled = true
Viola!!