Created
March 25, 2014 17:21
-
-
Save walidvb/9766734 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def mail_subscribers(book, attrs = {}) | |
| @book = book | |
| @body ||=attrs[:body] | |
| if attrs[:attachments] | |
| puts attrs[:attachments] | |
| attrs[:attachments].all? { | |
| |attachment| | |
| attachments[attachment[:filename]] = attachment[:content] | |
| } | |
| end | |
| mail(bcc: users.join(','), subject: attrs[:subject]) | |
| end | |
| def self.deliver_mail_chapter(book, chapter_index, attrs = {}) | |
| attachments = Array.new | |
| attachments.push({ | |
| :filename => "myAttachment.txt", | |
| :content => "some content" | |
| }) | |
| default_attrs = { | |
| :subject => "convert", | |
| :attachments => attachments | |
| } | |
| attrs = default_attrs.merge(attrs) | |
| mail_subscribers(book, attrs).deliver | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment