Sha256: 9495741352a803c6fa78d298e71a1d213ba47c3489bb8678bd06b82c1ab7f791
Contents?: true
Size: 1.27 KB
Versions: 68
Compression:
Stored size: 1.27 KB
Contents
Rack ==== For more info about using Rack applications, see the docs at {http://rack.rubyforge.org/} Basic usage involves storing data (e.g. images), then serving it in some form. A basic rackup file `config.ru`: require 'rubygems' require 'dragonfly' Dragonfly[:my_app_name].configure do |c| # ... configuration here end run Dragonfly:App[:my_app_name] See {file:Configuration} for more details. The basic flow is instantiate an app -> configure it -> run it. Example: Using to serve resized images -------------------------------------- `config.ru`: require 'rubygems' require 'dragonfly' app = Dragonfly[:images].configure_with(:imagemagick) run app This enables the app to use all the ImageMagick goodies provided by Dragonfly (see {file:Configuration}). By default the {Dragonfly::DataStorage::FileDataStore file data store} is used. In the console: app = Dragonfly[:images] # Store uid = app.store(File.new('path/to/image.png')) # ===> unique uid # Get the url for a thumbnail url = app.fetch(uid).thumb('400x300').url # ===> "/media/BAhbBlsHOgZmIg9hc..." Now when we visit the url `/media/BAhbBlsHOgZmIg9hc...` in the browser, we get a resized image! Mounting in Rack ---------------- See {file:URLs}
Version data entries
68 entries across 68 versions & 4 rubygems