Skip to content

Working with Images

zorec edited this page Nov 20, 2013 · 4 revisions

Best integration is acheived with dragonfly gem.

  1. You need to include following gems (and follow the instruction in dragonfly gem):
gem 'rack-cache', :require => 'rack/cache'
gem 'dragonfly', '~> 0.9.14'
  1. Then add following columns to the migration for the model you want to use image:
add_column table, :picture_uid,       :string
add_column table, :picture_name,      :string
add_column table, :picture_mime_type, :string
add_column table, :picture_size,      :integer
  1. Add following lines to the model
image_accessor :picture
validates_property :mime_type, :of => :picture, :in => Settings.image_mime_types, :case_sensitive => false

rails_admin do
  exclude_fields :picture_name, :picture_mime_type, :picture_size
end