Hmmm, I'm still not entirely sure what you are trying to do. Which of
the following scenarios does your app belong to?
- Certain tables should be kept in sync between two databases or even
the database as a whole, but the databases need to be on different
servers/locations: use database replication, some databases support it
and you don't have to worry about keeping them in sync.
- Certain tables should just be accessible by both applications, but
those tables can be on the same server: split out the common tables
into a new application and use ActiveResource to access it. If one of
the apps is not a Rails app, you'll have to develop an ActiveResource
compatible layer.
- Only certain records need to be synced and only by manual
interaction of the user: you can use what you were doing, but it will
become quite complex as you just found out. You'll need a common key
between the databases (you call it uuid and I'm guess you generate
them yourself), and you'll have to store that on either or both sides.
You can of course try and go with your original idea and force an
update of the primary key and all related keys (using raw sql executes
probably, or maybe a private method somewhere in Rails). Rails might
not be the ideal framework for that, since it's very opinionated. My
fear is also that you'll find yourself with an inconsistent database
sooner or later (probably even sooner than later). Am I the only one
who feels changing IDs in one database to keep another remote one in
sync doesn't feel quite right?
On 15 Jun 2011, at 18:46, Justin Stanczak wrote:
How do you handle say a one-many? Seems like the solution should be
at the ActiveRecord::Base level . This is why I was changing the id
system to uuid. That way rails could just update based on uuid.
On Wed, Jun 15, 2011 at 12:35 PM, Peter De Berdt <[email protected]
> wrote:
On 15 Jun 2011, at 18:25, Justin Stanczak wrote:
Yes, I'm starting to learn this. When I say distributed, I mean I'm
linking applications with rabbitmq and ruby amqp. I then pass a
message that's serialized in json. The issue is normal integer id's
between apps will clash, so I was going to use uuid as the id
instead.I'm guessing you are saying make the uuid another field,
and just update the object. So the two applications would maintain
their own id's, but match uuid's? Is there not a method of doing
this that already works. I know I'm not the first to pass objects
around.
Best regards
Peter De Berdt
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.