-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathREADME.txt
More file actions
39 lines (27 loc) · 771 Bytes
/
Copy pathREADME.txt
File metadata and controls
39 lines (27 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Mongoid::Grid
mongoid_grid is a GridFS plugin for Mongoid::Document
***NOTE: The rack helper is no longer included in this project. If you
need it, please switch to rack_grid: https://github.com/dusty/rack_grid
Installation
# git clone https://github.com/dusty/mongoid_grid.git
# gem build mongoid_grid.gemspec
# gem install mongoid_grid-0.0.x.gem
Usage
require 'mongoid_grid'
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
Inspired By
- http://github.com/jnunemaker/grip