i’ve been very persuaded by john nunemaker’s passionate writing that mongo db might be the next new thing i have to try. sure, sql databases are the norm, but mongo’s document-based database format rings truer to me the more of a rubyist i become.
gridfs is mongo’s way of storing file uploads within the database and with the release of its new ruby driver, using grid FS is faster and easier. check the simplicity in this example code =>
db = Mongo::Connection.new.db('testing')
grid = Mongo::Grid.new(db)
# returns object id
id = grid.put(File.read('mr_t.jpg'), 'mr_t.jpg')
# get the file using object id
file = grid.get(id)
# read the file from grid fs
puts file.read
# delete the file
grid.delete(id)
the active development of john’s mongomapper gem for rails models and grip plugin for gridfs should definitely be on anyone’s radar who is exploring nosql options.