mezis/appfab

View on GitHub
app/observers/notification/user_observer.rb

Summary

Maintainability
A
25 mins
Test Coverage
# encoding: UTF-8
class Notification::UserObserver < ActiveRecord::Observer
  observe :user

  def after_save(record)
    return unless record.account && record.account_id_changed?
    record.account.users.each do |account_user|
      next if account_user == record # don't get notified when I join
      Notification::NewUser.create!(recipient:account_user, subject:record)
    end
  ensure
    return true
  end

end