Skip to content

DatabaseOrFilesystemStorage

Squeegy edited this page Sep 12, 2010 · 5 revisions

Storing your images in the filesystem or the database each have their pros and cons. I won’t go into those here, I will just give you information about how to go about making either option work.

The recommended approach is file system storage. Declaration is simple:


  class Photo < ActiveRecord::Base
    acts_as_fleximage do
      image_directory 'path/to/images'
    end
  end

To store your images in the DB, simply include a binary column in your database with a special name: image_file_data. Fleximage will see that column on your model, and automatically store its images there. Then you can leave the image_directory off completely, making your class look more like:


  class Photo < ActiveRecord::Base
    acts_as_fleximage
  end
Clone this wiki locally