What is the best way to sync my rails model with an external database ? 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 ? thanks. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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.> > 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?> thanks.Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Dec 9, 2010 at 11:07 AM, Matteo Folin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> What is the best way to sync my rails model with an external database ? > > 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 ? > > thanks. > >the only time you need to reload the models is if the schema of the db changes, any other time it the data changes rails will always pull the latest data, it appears that what you want to know is how to update the view when the database changes. is that so ? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 sync db. There''s some better practices, general/typical solution pattern ? Thanks.> >> thanks. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org-- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
If your app doesn''t really have to do anything with the data (validate, transform, etc) then I''d try to solve this on the db level. MySQL replication comes to mind though I''m not sure how that will work with db views. Keep us posted on how it goes! Cheers, Simon On Dec 10, 8:58 am, Matteo Folin <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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 > sync db. > > There''s some better practices, general/typical solution pattern ? > > Thanks. > > > > >> thanks. > > > Best, > > -- > > Marnen Laibow-Koser > >http://www.marnen.org > > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.