0

I have a Rails app that works fine locally. It does not require any database. I am trying to deploy it using Heroku, but this is the only information I am getting in my logs as to why it's not working:

2018-09-14T17:27:28.074554+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calendarizer.herokuapp.com request_id=4da3eec1-23dd-4d1a-ae8f-7b05086d20fc fwd="65.207.79.74" dyno= connect= service= status=503 bytes= protocol=https
2018-09-14T17:27:28.469113+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calendarizer.herokuapp.com request_id=f079f20e-a9c1-4547-b563-3c2822b89e2d fwd="65.207.79.74" dyno= connect= service= status=503 bytes= protocol=https

My log level is set to DEBUG. No idea where else to look or how to tackle this problem.

EDIT:

I went back in the logs and I found this:

2018-09-14T17:37:19.872142+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.2.1/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `has_one_attached' for #<Class:0x00000007a055f8> (NoMethodError)

I had not heard of ActiveStorage before now, but it's not something I'm using (at least not intentionally).

Log dump:

2018-09-14T17:46:41.000000+00:00 app[api]: Build started by user username@gmail.com 2018-09-14T17:46:59.000000+00:00 app[api]: Build failed -- check your build logs 2018-09-14T17:47:09.445004+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calendarizer.herokuapp.com request_id=6dca7f6f-3afd-4bcd-b144-f63b85994472 fwd="65.207.79.74" dyno= connect= service= status=503 bytes= protocol=https 2018-09-14T17:47:09.792706+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calendarizer.herokuapp.com request_id=1818345c-2dfb-4a30-ada6-65ca3bbc04ea fwd="65.207.79.74" dyno= connect= service= status=503 bytes= protocol=https 2018-09-14T17:56:48.278447+00:00 app[api]: Starting process with command `bundle exec rake db:migrate` by user username@gmail.com 2018-09-14T17:56:52.733021+00:00 heroku[run.7080]: Awaiting client 2018-09-14T17:56:52.763164+00:00 heroku[run.7080]: Starting process with command `bundle exec rake db:migrate` 2018-09-14T17:56:52.907308+00:00 heroku[run.7080]: State changed from starting to up 2018-09-14T17:57:00.092474+00:00 heroku[run.7080]: Process exited with status 1 2018-09-14T17:57:00.107737+00:00 heroku[run.7080]: State changed from up to complete 2018-09-14T17:58:27.000000+00:00 app[api]: Build started by user username@gmail.com 2018-09-14T17:58:40.000000+00:00 app[api]: Build failed -- check your build logs 2018-09-14T17:59:08.348804+00:00 app[api]: Starting process with command `bundle exec rake db:migrate` by user username@gmail.com 2018-09-14T17:59:14.334567+00:00 heroku[run.7746]: State changed from starting to up 2018-09-14T17:59:14.252562+00:00 heroku[run.7746]: Awaiting client 2018-09-14T17:59:14.278462+00:00 heroku[run.7746]: Starting process with command `bundle exec rake db:migrate` 2018-09-14T17:59:22.174620+00:00 heroku[run.7746]: Process exited with status 1 2018-09-14T17:59:22.189708+00:00 heroku[run.7746]: State changed from up to complete 2018-09-14T17:59:56.283122+00:00 app[api]: Starting process with command `bundle exec rake db:migrate` by user username@gmail.com 2018-09-14T18:00:05.530380+00:00 heroku[run.7894]: State changed from starting to up 2018-09-14T18:00:05.579669+00:00 heroku[run.7894]: Awaiting client 2018-09-14T18:00:05.633999+00:00 heroku[run.7894]: Starting process with command `bundle exec rake db:migrate` 2018-09-14T18:00:20.779574+00:00 heroku[run.7894]: State changed from up to complete 2018-09-14T18:00:20.763154+00:00 heroku[run.7894]: Process exited with status 1 2018-09-14T18:01:58.718055+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calendarizer.herokuapp.com request_id=989475e7-affc-41a2-ade6-5cf21ce746a9 fwd="65.207.79.74" dyno= connect= service= status=503 bytes= protocol=https 2018-09-14T18:01:59.041312+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calendarizer.herokuapp.com request_id=38c77377-2758-4a31-9219-6dcb548a5b1e fwd="65.207.79.74" dyno= connect= service= status=503 bytes= protocol=https

thumbtackthief
  • 6,093
  • 10
  • 41
  • 87

2 Answers2

0

Heroku usually wants to see some kind of database (ie pg) to run if something is going to get saved, which I believe having ActiveRecord in your app is going to imply (even if you don't intend to use it). So you have two solutions I believe. In your dev & test environment you likely have sqlite3 as your database (you can look in your gemfile), but Heroku doesn't work with sqlite3.

Option 1: Disable ActiveRecord in your app - Following this post: Disable Active Storage in Rails 5.2

Option 2: Add a database to your production environment for heroku, so it's happy: - in your gemfile see if you have a production group already

group :production do
  • if not add it
  • add in the pg gem:

    gem 'pg'

So you should end up with something like this in your gemfile:

group :production do
  gem 'pg'
end

Then commit and push to Heroku. You may need to restart the Dynos in Heroku, and you may need to create the database files on heroku too:

heroku run rails db:create

You should be up and running now.

CanuckT
  • 321
  • 1
  • 3
  • 14
0

For me the problem was that the adapter in database.yml was sqlite3. So I changed the production section of config/database.yml to:

production:
  adapter: postgresql
  encoding: unicodeubyonrails.org/configuring.html#database-pooling
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  database: myapp_production
  username: myapp
  password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>
Daniel Garcia
  • 1,382
  • 1
  • 10
  • 9