You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Active Record Observers are the tool for the job. You may add your notifications logic in a file named app/models/badges_sash_observer.rb. Follows a working example:
classBadgesSashObserver < ActiveRecord::ObserverobserveMerit::BadgesSash# A badge_sash has badge_id and sash_id foreign keysdefafter_create(badge_sash)# In this case the User model has a `has_merit` call,# and so has a sash_id foreign keyuser=User.find_by_sash_id(badge_sash.sash_id)MyAppMailer.badge_granted(badge_sash.badge_id,user.id).deliver# And whatever else your app uses for sending notifications!endend