I'm trying to use Wisper with Rails 4 / AR and encountering an issue.
Let's say I have Email
and Creep
AR models, and I want the Creep
to know when a reply was received (Creep
is not necessarily the sender...)
So I do:
email = Email.create! params
creep = Creep.last
email.subscribe(creep, on: :reply_received, with: :success)
and if immediately do:
email.publish :reply_received
It will work (Creep
instances have a success method).
However, if i later do:
email = Email.find(id)
or:
email = Email.last
The event is not broadcast. I'm guessing this is because the new email is a different instance, and thus has no listeners subscribed. What am I doing wrong?