The Changelog

Open Source moves fast. Keep up.

A Nunemaker Joint

It’s never been easier to do file uploads with MongoMapper and GridFS. Joint, from MongoMapper creator John Nunemaker, is a MM plugin that adds some nice convenience methods to your models:

class Foo
  include MongoMapper::Document
  plugin Joint

  attachment :image
  attachment :pdf

By declaring these two attachments, you automagically get accessors for image and pdf. The setter methods take any IO (File, Tempfile, etc) and the getter methods return a GridIO type from the Ruby driver.

John even throws in some nifty proxy goodness:

[Source on GitHub][John on Episode 0.1.1]

Have comments? Send a tweet to @TheChangelog on Twitter.

Subscribe to The Changelog Weekly – our weekly email covering everything that hits our open source radar.