Summary
Mongomatic::Plugins::Grid is a Grid plugin for Mongomatic
Support is built in for rack_grid and rack_grid_thumb to generate URLS and thumbnails:
http://github.com/dusty/rack_grid
http://github.com/dusty/rack_grid_thumb
Installation
# gem install matic_grid
Usage
require 'matic_grid'
class Monkey < Mongomatic::Base
include Mongomatic::Plugins::Grid
attachment :image, :prefix => 'grid'
end
m = Monkey.new(:name => 'name').insert
# To add an attachment
m.image = File.open('/tmp/me.jpg')
m.update
# To remove an attachment
m.image = nil
m.update
# To get the attachment
m.image.read
# To get the URL for rack_grid
m.image_url # /grid/4e049e7c69c3b27d53000005/me.jpg
# To get the thumbail URL for rack_grid_thumb
m.image_thumb('50x50') # /grid/4e049e7c69c3b27d53000005/me_50x50.jpg
Inspired By
- http://github.com/jnunemaker/grip
Mongomatic::Plugins::Grid is a Grid plugin for Mongomatic
Support is built in for rack_grid and rack_grid_thumb to generate URLS and thumbnails:
http://github.com/dusty/rack_grid
http://github.com/dusty/rack_grid_thumb
Installation
# gem install matic_grid
Usage
require 'matic_grid'
class Monkey < Mongomatic::Base
include Mongomatic::Plugins::Grid
attachment :image, :prefix => 'grid'
end
m = Monkey.new(:name => 'name').insert
# To add an attachment
m.image = File.open('/tmp/me.jpg')
m.update
# To remove an attachment
m.image = nil
m.update
# To get the attachment
m.image.read
# To get the URL for rack_grid
m.image_url # /grid/4e049e7c69c3b27d53000005/me.jpg
# To get the thumbail URL for rack_grid_thumb
m.image_thumb('50x50') # /grid/4e049e7c69c3b27d53000005/me_50x50.jpg
Inspired By
- http://github.com/jnunemaker/grip