Attachments using actionmailer

Hello,   I have seen examples for attachment using action mailer in rails. They all say that you need to mention the content type of the file type attached and in the exmaple they give the content type explicitly(i.e static in code).

What i need is how can i find the content/type of the file dynamically. This is because i wont come to know which file the user will be attaching..

The other problem is that if you clicked on the attachment browse button and have attached a file by mistake there is no way to deattach the file. SO the install.log has now been attached throgh my post by mistake but i cannot remove it.

Please help

Thank you.

Attachments: http://www.ruby-forum.com/attachment/2122/install.log

I think the mime-types gem is what you want:

sudo gem install mime-types

api docs are here: http://mime-types.rubyforge.org/