module Paperclip::Storage::Database::ControllerClassMethods

Public Class Methods

included(base) click to toggle source
# File lib/paperclip/storage/database.rb, line 227
def self.included(base)
  base.extend(self)
end

Public Instance Methods

downloads_files_for(model, attachment, options = {}) click to toggle source
# File lib/paperclip/storage/database.rb, line 230
def downloads_files_for(model, attachment, options = {})
  define_method("#{attachment.to_s.pluralize}") do
    #FIXME: Handling Namespaces
    model_record = Object.const_get(model.to_s.camelize.to_sym, false).find(params[:id])
    style = params[:style] ? params[:style] : 'original'
    send_data model_record.send(attachment).file_contents(style),
              :filename => model_record.send("#{attachment}_file_name".to_sym),
              :type => model_record.send("#{attachment}_content_type".to_sym)
  end
end