Module: SimpleNotification::Methods

Defined in:
lib/simple_notification/can_be_tracked.rb

Instance Method Summary collapse

Instance Method Details

#notify(recipient, trackable, message) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/simple_notification/can_be_tracked.rb', line 3

def notify(recipient, trackable, message)
  owner = current_user
  owner = User.new if owner == nil

  if owner == recipient
    return
  end

  notification = Notification.create(owner_id: owner.id, recipient_id: recipient.id, message: message)
  trackable.notifications << notification
end