rails class reminders code example
Example 1: rails class sti reminders
class AddNotes < ActiveRecord::Migration[5.2]
def change
create_table :notes do |t|
t.string :type
t.string :title
t.boolean :is_completed
t.jsonb :data, default: {}
t.timestamps
end
add_index :notes, :data, using: :gin
end
end
Example 2: rails class note reminders
ReminderJob = Struct.new(:event) do def enqueue(job) job.delayable = event job.save! end def perform event.send_reminder end def queue_name 'reminder_queue' endend
Example 3: rails class note reminders
after_save :new_reminder def new_reminder Delayed::Job.enqueue(ReminderJob.new(self), { run_at: self.when_to_run }) end def send_reminder