DRB ActiveRecord and Database Hijacking (ActsAsFerret also!)
DiggBlinkRedditDeliciousTechnorati
question by spike | Moderate
Hi there, in relation to this:
http://programmerassist.com/article/302
I have an app that hijacks the database based upon the domain name requested. It's basically a content management system for schools and rather than duplicate the app we decided to keep the code central but maintain seperate databases for each school (as per our old version in PHP).
Everything works nicely except when we start working with actsasferret drb server. It's a seperate server that aaf accesses to index records and also search the index. When re-indexing the database I need to manually change the connection that the drb server uses each time I begin to index another database, and this works well. The problem comes when my rails application goes to automatically index records when a user adds a new item to the cms etc... The creator of aaf informs me that the drb server will use whatever AR connection is has at the time and that AAF just sends the class name and ID of the record to index. This should mean that if the drb server has the wrong connection set up then it will fail to index the record properly.
The weird thing is that everything does work. I've tested it by setting up three different schools and adding a record one after the other to each school. then searching one after the other. The records are found approptiately indexed. The only anomoly is that the last school that I search (the one that had a record added after all the rest) doesn't find the record in the index until you run the search about 3 times.
My question is, does DRB magically pick up the hijack from Application.rb when it runs and then interacts with the DRB server?
Hope someone can help :)
Cheers,
Brendon
Post reply
Subscriptions
Got a Ruby Question?
Just Sign Up and ask the top Ruby experts!
|