Skip to content

Instantly share code, notes, and snippets.

@joeljackson
Created February 21, 2013 08:08
Show Gist options
  • Save joeljackson/5003095 to your computer and use it in GitHub Desktop.
Save joeljackson/5003095 to your computer and use it in GitHub Desktop.
Your class, no refactoring
class Photo < ActiveRecord::Base
belongs_to :user
has_many :notifications
has_attached :picture
after_create :notify_users
def notified_users
User.where("id in (?)", self.notifications.map(&:user_id))
end
private
def notify_users
UserNotifier.new(self).notify
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment