Class: NoteObserver

Inherits:
ActiveRecord::Observer
  • Object
show all
Defined in:
app/models/note_observer.rb

Instance Method Summary collapse

Instance Method Details

#after_create(note) ⇒ Object


4
5
6
# File 'app/models/note_observer.rb', line 4

def after_create(note)
  publish(:create, note)
end

#publish(type, note) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/note_observer.rb', line 8

def publish(type, note)
  Juggernaut.url = ENV['JUGG_URL']
  Juggernaut.publish("/observer/note/#{note.animal.id}", {
    id: note.id,
    type: type,
    created_at: Time.now.strftime('%a, %b %e at %l:%M'),
    klass: note.class.name,
    record: note,
    user: note.username
  })
end