Class: Notification
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Notification
- Includes:
- AASM
- Defined in:
- app/models/notification.rb
Overview
create_table :notifications do |t|
t.string :type
t.references :created_by
t.text :message
t.references :notification_type
t.string :current_state
t.text :custom_fields
t.
end
add_index :notifications, :notification_type_id add_index :notifications, :created_by_id add_index :notifications, :type
Class Method Summary collapse
-
.create_notification_of_type(notification_type, custom_fields = {}, created_by = nil) ⇒ Object
Creates a Notification record with the notification type passed.
Instance Method Summary collapse
-
#deliver_notification ⇒ Object
Delivers notification, called by the notifications delayed job this is a template method and should be overridden by sub class.
Class Method Details
.create_notification_of_type(notification_type, custom_fields = {}, created_by = nil) ⇒ Object
Creates a Notification record with the notification type passed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/notification.rb', line 45 def create_notification_of_type(notification_type, custom_fields={}, created_by=nil) notification_type = notification_type.class == NotificationType ? notification_type : NotificationType.iid(notification_type) notification = self.create( created_by: created_by, notification_type: notification_type ) notification.custom_fields = custom_fields notification.save! notification end |
Instance Method Details
#deliver_notification ⇒ Object
Delivers notification, called by the notifications delayed job this is a template method and should be overridden by sub class
65 66 |
# File 'app/models/notification.rb', line 65 def deliver_notification end |