Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Less simple
class Membership
belongs_to :user
belogns_to :group
after_save :send_notifications, if: ->(m) { m.accepted_changed? && m.accepted? }
def send_notifications
NotificationMailer.accepted(self, user).deliver!
PushNotifcations::NewMembership.new(self, user).dispatch!
group.admins.each do |admin|
NotificationMailer.accepted_admin(self, admin).deliver!
PushNotifcations::NewMembershipForAdmin.new(self, user).dispatch!
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment