Marnen Laibow-Koser wrote in post #967437:
Matteo Folin wrote in post #967435:
What is the best way to sync my rails model with an external database ?
What exactly is your use case for this? It's hard to give advice on a
question that vague.
Ok. I manage products data in a rails e-commerce but I need sync with
data in an external ERP. I can't operate on ERP data, they could give me
only some views. I see these views as external db connection in rails,
but I wouldn't use cron script for checking for change, I would like
have a callback on change made by the ERP. The only solution that I can
see is that the ERP made a call to my app (/product/updated/115) and
then I sync that product.
But if there was possibly made activerecord knowing what the ERP is
doing on the external db...
I can use a callback on my model to update the external table. But in
the other direction, when the external db change some data and would
sync my activerecord model ? I can only think at a REST request of
update of some record. Or a cron sync script, problematic with large db.
There's better solutions ?
From the little you've said, REST sounds like a good solution.
But...why do you need to synchronize at all? Can you just query the
external DB as necessary and avoid duplicating the data?
In general is a typical problem of integration with company resources.
They don't want give you access direct on db, but they want you work on
There's some better practices, general/typical solution pattern ?