I encountered an application error after having deployed my Ruby on Rails app to Heroku. The app is developed on Cloud9 from AWS and is called "wcslux_app". The app is equivalent to the hello_app from Hartl's rails_tutorial. In the Log file, I can see there is an error code H10 on GET with path "/" and ""/favicon.ico".
After having followed the tutorial my app is not working in production on Heroku. I executed following commands to deploy the wcslux_app:
source \<(curl -sL <https://cdn.learnenough.com/resize>)
rake log:clear
rake tmp:clear
source \<(curl -sL <https://cdn.learnenough.com/heroku_install>)
heroku login --interactive
heroku create
git push heroku main
When visiting https://sheltered-beach-35205-f93f5210b58a.herokuapp.com, I was expecting to have the same results as obtained in my development environment IDE Cloud of cloud9 of AWS.
Gem file:
group :development, :test do
gem "sqlite3", "1.4.2"
gem "debug", "1.5.0", platforms: %i[ mri mingw x64_mingw ]
end
group :production do
gem "pg", "1.3.5"
end
The setup of specific adapters for each environment in the database.yml config file is the solution . I have defined a sqlite adapter for development and test environments and a Postgres adapter for production environment.
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/test.sqlite3
production:
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
database: wcslux_app_production
username: wcslux_app
password: <%= ENV['WCSLUX_APP_DATABASE_PASSWORD'] %>