Check to see if we can connect to the db before accessing it. Fixes #396.

Fix heroku precompile assets breaking with Rails 4. Fixes #396.

This fails specs for unrelated reasons that have been addressed in #404. I have been able to deploy to Heroku with an app running Rails 4 using this fork. It should be good to merge.