Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
MongoMapper GridFS Attachment gem

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.DS_Store
.gitignore
LICENSE
README.rdoc
Rakefile
VERSION
grip.gemspec

README.rdoc

grip

GridFS attachments for MongoMapper

installation

The grip gem is hosted on gemcutter.org:

gem install miso grip

Usage (See tests for better docs)

class Doc
  include MongoMapper::Document
  include MongoMapper::Grip::HasAttachment

  has_grid_attachment :image, :versions => {:thumb => {:width=>50,:height=>50}}

end

image = File.open('foo.png', 'r')
@doc = Doc.create(:image => image)

puts @doc.image.name 
=> "image"
puts @doc.image.file_size
=> 100
puts @doc.image.file_name
=> "foo.png"
puts @doc.image.grid_key
=> "docs/<id>/image"

# works on nested variants as well

puts @doc.image.thumb.name 
=> "thumb"
puts @doc.image.thumb.file_size
=> 50
puts @doc.image.thumb.file_name
=> "foo.png"
puts @doc.image.thumb.grid_key
=> "attachments/<id>/thumb"

@doc.image.file # contents read from gridfs for serving from rack/metal/controller
Something went wrong with that request. Please try again.