THE ZEPINT NETWORK

programmer assist

Ruby Ruby XML Feeds

Ruby Questions Ruby Solutions Ruby Articles

Ruby is a reflective, dynamic, object-oriented programming language. It combines syntax inspired by Perl with Smalltalk-like object-oriented features, and also shares some features with Python, Lisp, Dylan, and CLU. Ruby is a single-pass interpreted language. Its official implementation is free software written in C.

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!

Search via Google

User Login

Email Address

Password

Ruby Experts

Rank Expert Points
#1 Srirangan 1500
This a list of the Top Ruby experts, how many points do you have?

Leading Experts

Rank Expert Points
#1 frankzzsword 4650
#2 Bejaan 2950
#3 csfreak 1100
#4 Anurag 700
#5 keyvez 700
#6 nnarasimha 600
#7 Nakata 600
#8 martinig 600
#9 mastercomputers 550
#10 Abhishek Chatterjee 250
#11 Abels 250
#12 Huntress 150
#13 Adkron 150
#14 Yogesh 100
#15 lexxwern 100
This is a list of overall best performing experts, how many points do you have?