I'm running Rails 3, and I've got several controllers that all do something like the following:
@db = Mongo::Connection.new.db(MONGOID_CONFIG['database'])
I don't want to have multiple connections to the database, so the natural thing would seem to be to wrap @db in some singleton that's initialized when I start the app. My question is, how to do that?
My first thought was to use a helper, but I'm told that those are only recommended for generating view stuff, and obviously views shouldn't be directly accessing the database. What else is there? Write a plugin? :)