Brian wrote: > > Is there any built-in way to handle this in rails (or a popular plugin > that can do this)? My very initial investigation seems to indicate a > specific table can be stored on another DB, but that ALL of the rows > are stored on that DB. I can't split this up across multiple servers.
As far as I know, you're right that you can only specify a different DB on a per-model basis. But you could make sub-classes of each of your models, one per each db, and then specify the different DB on each of those sub-classes. But then when doing a fetch, you'd have to choose the right model to do the fetch from -- but of course, that's kind of the point of why you can't have more than one db on just ONE model -- how would Rails know what DB to go to when you simply tried to do a Model.find on that model? I'm not really feeling confident that the architecture you're proposing really is the best solution to scaling up, but if you wanted it, I think ActiveRecord could support it in that manner -- by first writing your models, and then providing N sub-classes of each model you want to 'partition' to N databases. You could even provide some code to do this 'dynamically', you wouldn't need to (and wouldn't want to) actually hand-code a separate file on disk for each model. All the associations defined on the 'base' model would need to be re-defined for each model sub-class to use the appropriate destination model-subclass. This could also be done in an automated dynamic way. And then you'd need to provide some helper methods to figure out _which_ model to use for a given fetch (Model.find) operation. I'm not aware of any plug-in that already does this. I'm not sure it's a good idea, like I said, but I'm no expert. I think you'd have to write the logic yourself, but I think it's perfectly do-able within ActiveRecord's architecture. But no doubt it will end up somewhat more complicated to get working right than it seems at first, such things always do. Jonathan -- 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 [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 -~----------~----~----~----~------~----~------~--~---

