gottfrois / dashing-rails

The exceptionally handsome dashboard framework for Rails.
MIT License
1.45k stars 149 forks source link

Heroku instance doesn't work with database_connection.rb #74

Closed digitalWestie closed 9 years ago

digitalWestie commented 9 years ago

I have a basic dashing rails app and I've followed the wiki on running dashing-rails on heroku but I get the following error:

PG::ConnectionBad (could not connect to server: No such file or directory
2015-05-12T16:40:18.166407+00:00 app[web.1]: Started GET "/dashing/" for 2.120.137.89 at 2015-05-12 16:40:18 +0000
2015-05-12T16:40:18.168457+00:00 app[web.1]:    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
2015-05-12T16:40:18.168456+00:00 app[web.1]:    Is the server running locally and accepting

As an experiment I commented out the database_connection.rb code and it works okay.

=begin
Rails.application.config.after_initialize do
  ActiveRecord::Base.connection_pool.disconnect!

  ActiveSupport.on_load(:active_record) do
    config = Rails.application.config.database_configuration[Rails.env]
    config['reaping_frequency'] = ENV['DB_REAP_FREQ'] || 10 # seconds
    config['pool']              = ENV['DB_POOL']      || 5
    ActiveRecord::Base.establish_connection(config)
  end
end
=end

Has the same happened to anybody else? Also, could somebody explain a little bit about what the above code does, and if it's needed?

gottfrois commented 9 years ago

So you are probably missing the pgsql heroku addon. Dashing-rails does not really need a SQL database to work but your rails application mounting dashing is probably using active record by default.

It is up to you to setup the rails application the way you want. If you want to use mongodb you would deactivate active record related code and install the mongodb heroku addon for example.

gottfrois commented 9 years ago

Regarding the database_connection.rb here is more information on why it's needed https://devcenter.heroku.com/articles/concurrency-and-database-connections#threaded-servers

digitalWestie commented 9 years ago

Thanks for the info, the code in the heroku article has a few extra lines that might be missing so I'll try those out. Edit; yes I've got the pgsql addon