public
Description: Treat an ActiveRecord model as a file attachment, storing its patch, size, content type, etc.
Homepage: http://weblog.techno-weenie.net
Clone URL: git://github.com/technoweenie/attachment_fu.git
Click here to lend your support to: attachment_fu and make a donation at www.pledgie.com !
nbibler (author)
Wed Jun 25 19:08:14 -0700 2008
commit  a74ea929dd0d061da887872f8cde07016524dcc4
tree    cf513104782dcb9eada0845447f5449674d1422f
parent  e475cf78a49ede1ba6c83fdae7028d7d9da4cd85
attachment_fu / init.rb
100644 17 lines (13 sloc) 0.615 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require 'tempfile'
 
Tempfile.class_eval do
  # overwrite so tempfiles use the extension of the basename. important for rmagick and image science
  def make_tmpname(basename, n)
    ext = nil
    sprintf("%s%d-%d%s", basename.to_s.gsub(/\.\w+$/) { |s| ext = s; '' }, $$, n, ext)
  end
end
 
require 'geometry'
ActiveRecord::Base.send(:extend, Technoweenie::AttachmentFu::ActMethods)
Technoweenie::AttachmentFu.tempfile_path = ATTACHMENT_FU_TEMPFILE_PATH if Object.const_defined?(:ATTACHMENT_FU_TEMPFILE_PATH)
FileUtils.mkdir_p Technoweenie::AttachmentFu.tempfile_path
 
$:.unshift(File.dirname(__FILE__) + '/vendor')