Viking Hammer

Archive for March, 2010

Using function scope to build a jQuery event handler

So here’s another cool thing from the development of poll4.me that might interest some people. When I’m creating or editing polls, I have the option of adding an arbitrary number of answers. I don’t want to just leave an infinite number of form fields for the user to potentially fill in if he wants to [...]

Authenticating with MongoMapper

For my new poll4.me application, I’m using MongoDB and need to be able to connect to the authenticated database in production, but not necessarily in my development environment. I couldn’t find anywhere online that shows specifically how to do that, so I’ll post it here. MongoMapper.connection = Mongo::Connection.new(config['db_hostname']) MongoMapper.database = config['db_name'] if config['db_username'] MongoMapper.connection[config['db_name']].authenticate(config['db_username'], config['db_password']) [...]