When you make a new Ruby on Rails app, there are a few changes you must make to your app so that the production environment (Heroku) functions properly.
Firstly, if you don't have the Heroku CLI installed and the app setup. Go do that. This page isn't for that.
Next, in your Gemfile, make sure that if you're using anything other than postgreSQL for your Dev DB, you isolate it. Heroku uses postgreSQL.
Heroku also uses some other gem that the dev environment doesn't need. So you should have different gems for dev and production. Like so:
group :development, :test do
gem 'sqlite3' # SQLite3 gem for dev and test environments
end
group :production do
gem 'pg' # the postgreSQL gem
gem 'rails_12factor' # that special gem that Heroku needs
end
Make sure to bundle install
after making that change.
You'll also need to update your database.yml file so it reflects the change in DB adapter. Here's a template you can use:
default: &default
pool: 5
timeout: 5000
development:
<<: *default
adapter: sqlite3
database: db/development.sqlite3
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
adapter: postgresql
encoding: unicode
If things still aren't working, check out the Heroku Rails document here.