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
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:
- 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 - Member actions under each attachable model that would look like this
/items/4546/email - Multipart form?
- 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