mercredi 11 mars 2015

Observing database changes made by other app

I've got a rails app and an admin app which share the same database and the models. Although not all models in admin are in the rails app and vice versa.


So when admin makes changes to certain models i.e User model, I want to be able to pick up that change on the rails app side. And User model is one of the models that is shared between both rails app and admin app.


I've tried with rails observers but since the change is made from different app I'm suggesting that this is the reason why it doesn't work, this is my observer :



class UserObserver < ActiveRecord::Observer
observe :user

def after_create(record)
binding.pry
end

def after_destroy(contact)
binding.pry
end
end


And my application config :



config.active_record.observers = :user_observer


So I'm wondering what are my alternatives, I basically need to know when users are updated or destroyed. And I might want to observer more than one model, but one model is enough for now. What else can I try?


Aucun commentaire:

Enregistrer un commentaire