Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created August 20, 2009 08:00
Show Gist options
  • Save jugyo/170901 to your computer and use it in GitHub Desktop.
Save jugyo/170901 to your computer and use it in GitHub Desktop.
# add a utility method 'set_file'
module Technoweenie
module AttachmentFu
module InstanceMethods
def set_file(path, content_type = Mime::TEXT)
raise ArgumentError, "No such file - #{path}" unless File.exists?(path)
self.filename = File.basename(path)
self.content_type = content_type
set_temp_data File.read(path)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment