-
-
Save harlow/bfe3820adca57f7c1808 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
class NotesController < ApplicationController | |
def create | |
@note = @project.notes.create params[:note].merge( | |
creator: current_user, subscribers: extract_subscribers(params[:note])) | |
@note.subscribers.each { |subscriber| Subscriptions.note(@note, subscriber).deliver } | |
end | |
end | |
class Subscriptions < ActionMailer::Base | |
def note(note, recipient) | |
@note = note | |
mail to: recipient.email_address, subject: note.title | |
end | |
end | |
# To this instead | |
class NotesController < ApplicationController | |
def create | |
@note = @project.notes.create params[:note].merge( | |
creator: current_user, subscribers: extract_subscribers(params[:note])) | |
# Returns an a Mailbag of mail objects, that responds to deliver | |
Subscriptions.to(@note.subscribers.collect(&:email_address)).note(@note).deliver | |
end | |
end | |
class Subscriptions < ActionMailer::Base | |
def note(note) | |
@note = note | |
mail subject: note.title | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment