-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
I'm seeing a lot of heroku customers run into issues with running the rake assets:precompile task during our slug compilation task for Rails 3.1. For security reasons, we aren't passing the ENV vars to this box and shouldn't need the MongoDB connection strings to compile the assets. Since, rails is booting the whole environment in order to do this it loads the mongoid railtie.
It'd be nice if mongoid could elegantly handle this case. It seems there are a few options:
1. The railtie could rescue the Mongo::ConnectionFailure something like this: https://gist.github.com/3a15d6b13aa404dbb41d
In general, I don't like rescuing errors.
2. The railtie could detect if the ENV vars are nil for the Rails.env and not load the connection, since it will surely fail: https://gist.github.com/04a8aea95f7b6adce6c6
3. Mongoid should lazily load the connection like ActiveRecord does and not eagerly try to connect on bootup. I was looking into passing the option :connect => false as an option parameter as not to eagerly connect, but this has many other implications.