I would like to know what will be the best way to save binary files 'in database'. Of course they wi开发者_如何学JAVAll be on the disk as files, but i need some 'link' to them in the DB. Any great solutions?
Use Paperclip to attach a file to a model.
Say you have a mortgage that has a document
class Mortgage < ActiveRecord::Base
has_attached_file :document
end
Later:
mortgage = Mortgage.find(params[:id])
document = mortgage.document
Paperclip is usually used with images, but works with all types of files. You can easily store on s3 as well.
If you don't have anything against mongodb and gridfs, there's an example here http://socialmemorycomplex.net/2010/06/02/gridfs-with-mongoid-and-carrierwave-on-rails-3/
精彩评论