# Attachment to emails

**URL:** <https://www.ruby-forum.com/t/attachment-to-emails/131336>\
**Category:** Rails\
**Created:** [March 8, 2008, 10:19am UTC](https://www.ruby-forum.com/t/attachment-to-emails/131336 "2008-03-08T10:19:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grayson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@grayson](https://www.ruby-forum.com/u/grayson)\
**Post date:** [March 8, 2008, 10:19am UTC](https://www.ruby-forum.com/t/attachment-to-emails/131336/1 "2008-03-08T10:19:57Z")

</div>

Hello,

I followed this excellent example from NovaWave (thank you!) and  
implemented a mini-email system

[http://www.novawave.net/public/rails\_messaging\_tutorial.html](http://www.novawave.net/public/rails_messaging_tutorial.html)

Next I wanted to add the ability to attach different models to the  
email. For this I created a model called attachment that belongs to the  
message and has polymorphic relationships with a couple of other models  
(pretty cool ehh, OLE eat my dust)

What I can’t figure out is when/where/how to initiate the attachment. I  
can test this out and it works just fine

Attachment.new(:attachable =\> Item.find(:first), :message =\>  
Message.find(:first))

and the attachable\_type sets correctly, etc.

My problem is that I still don’t understand REST well enough to figure  
out where this belongs in the grander scheme of things. Here are some  
options that I’m considering:

1. New actions one for each attachment type that all point to the same  
create  
action under the sent\_controller (see the novawave doc). I think the  
url would look like this: /sent/new/item/4546
2. Member actions under each attachable model that would look like this  
/items/4546/email
3. Multipart form?
4. Somewhere as part of current\_user.sent\_messages.build

For once, I’d like to do things the proper RoR way.

Thank you kindly.

GP
