Ruby on Rails - adding attachments in ruby on rails - ruby on rails tutorial - rails guides - rails tutorial - ruby rails
- ActionMailer will allows attaching files.
attachments['filename.jpg'] = File.read('/path/to/filename.jpg')
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
Default, attachments will be encoded with Base64. To change this, we can add a hash to the attachments method
attachments['filename.jpg'] = {
mime_type: 'application/gzip',
encoding: 'SpecialEncoding',
content: encoded_content
}
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
We can also add inline attachments
attachments.inline['image.jpg'] = File.read('/path/to/image.jpg')