Mongoid::Grid / Rack::Grid Mongoid::Grid is a plugin for mongoid that uses GridFS. Heavily inspired by grip (http://github.com/jnunemaker/grip) Rack::Grid is used to serve a GridFS file from rack. Mostly copied from http://github.com/skinandbones/rack-gridfs Download the source at http://github.com/dusty/mongoid_grid Installation Put the libraries in your project however you want. You could make a gem to install or use with bundler. # git clone http://github.com/dusty/mongoid_grid # cd mongoid_grid # gem build mongoid_grid.gemspec Then require the libraries you want to use. require 'mongoid/grid' require 'rack/grid' Usage class Monkey include Mongoid::Document include Mongoid::Grid field :name attachment :image end m = Monkey.create(:name => 'name') # To add an attachment m.image = File.open('/tmp/me.jpg') m.save # To remove an attachment m.image = nil m.save # To get the attachment m.image.read # To use Rack::Grid with Sinatra configure do use Rack::Grid, :database => 'my_db' end <img src="<%= m.image_url %>" alt="<%= m.image_name %>" />
Project
halfbyte-mongoid_grid
Plugin for Mongoid to use GridFS and a Rack helper
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
Development
Dependencies
Runtime
>= 0
>= 1.9
Project Readme