# Actionmailer + attachment\_fu

**URL:** <https://www.ruby-forum.com/t/actionmailer-attachment-fu/113007>\
**Category:** Rails\
**Created:** [August 26, 2007, 1:49am UTC](https://www.ruby-forum.com/t/actionmailer-attachment-fu/113007 "2007-08-26T01:49:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![patternhunter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/71c47a/32.png) [@patternhunter](https://www.ruby-forum.com/u/patternhunter)\
**Post date:** [August 26, 2007, 1:49am UTC](https://www.ruby-forum.com/t/actionmailer-attachment-fu/113007/1 "2007-08-26T01:49:38Z")

</div>

> image model

class Image \< ActiveRecord::Base  
has\_attachment  
end

> mailman controller

class Mailman \< ActionMailer::Base  
def receive(email)  
email.attachments.each do |attachment|  
Image.create :uploaded\_data =\> attachment  
end  
end  
end

> I got returned email with error messages

Command died with status 1: “/usr/local/bin/ruby  
/home/email\_test/script/runner ‘Mailman.receive(STDIN.read)’”. =  
Command  
output:  
=  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/runner.rb:47:  
/usr/local/lib/ruby/1.8/tempfile.rb:46:in `initialize': cannot = generate tempfile =`/home/email\_test/script/…/config/…/tmp/attachment\_fu/11862540901020801=  
593\_f62fd725ce18176-9.jpg’  
(RuntimeError) from  
=  
/home/email\_test/script/…/config/…/vendor/plugins/attachment\_fu/lib/tec=  
hnoweenie/attachment\_fu.rb:170:in  
`new' from = /home/email_test/script/../config/../vendor/plugins/attachment_fu/lib/tec= hnoweenie/attachment_fu.rb:170:in`write\_to\_temp\_file’ from  
=  
/home/email\_test/script/…/config/…/vendor/plugins/attachment\_fu/lib/tec=  
hnoweenie/attachment\_fu.rb:304:in  
`write_to_temp_file' from = /home/email_test/script/../config/../vendor/plugins/attachment_fu/lib/tec= hnoweenie/attachment_fu.rb:294:in`temp\_data=3D’ from  
=  
/home/email\_test/script/…/config/…/vendor/plugins/attachment\_fu/lib/tec=  
hnoweenie/attachment\_fu.rb:259:in  
`uploaded_data=3D' from = /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/b= ase.rb:1672:in`send’ from  
=  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/b=  
ase.rb:1672:in  
`attributes=3D' from = /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/b= ase.rb:1671:in`each’ … 11 levels… from  
=  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/runner.rb:47  
from =  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’ from /home/email\_test/script/runner:3

---

<div class="post-metadata">

**Author:** ![patternhunter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/71c47a/32.png) [@patternhunter](https://www.ruby-forum.com/u/patternhunter)\
**Post date:** [August 26, 2007, 1:56am UTC](https://www.ruby-forum.com/t/actionmailer-attachment-fu/113007/2 "2007-08-26T01:56:39Z")

</div>

On 8/25/07, Sean K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> def receive(email)
> email.attachments.each do |attachment|
> Image.create :uploaded_data => attachment
> end
> end
> 
> ```
> 
> end

You’re not uploading data, so it’s not really appropriate to use that  
method. You’ll have to set the fields manually then (filename,  
content type, etc). A future update to the plugin will be able to  
guess the content type for you based on the file.

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)
