Sending attachment with Actionmailer in RubyonRails on-the-fly

Normally Models upload files. The actual file is accessible via the tempfile accessor, though some of its interface is available directly for convenience. Uploaded files are temporary files whose lifespan is one request. When the object is finalized Ruby unlinks the file, so there is no need to clean them with a separate maintenance task. […]