Hi!

On Wed, Sep 19, 2007 at 03:39:14PM +0200, Matt Valblade wrote:
[..]
> 
> The problem is that the ferret index is not updated when I add/delete 
> information in my database (because I use an external application 
> (written in Ruby) to fill my database and I haven't acces save/destroy 
> rails model functions (overloaded by the acts_as_ferret plugin...))
> 
> ---------
> 
> I thought to 2 solutions :
> 
> - WebService (WSDL) that give me acces to save/destroy function of my 
> rails app
> - Update Ferret index "On the fly" when inserting new values in 
> database.
> 
> ----------
> 
> I prefer the second solution because the first risks to be too slow, and 
> I need rapidity.
> 
> Finaly, the question is : How can I update a Ferret index out of my 
> rails application ?

The safest way would be to talk to Ferret's DRb server. If you don't do
any updates to the index at all through your web app, you might also
just use plain Ferret to update the index.

Code for adding a record to the index via DRb might look like this:

server = DRbObject.new(nil, 'druby://localhost:9010')
server << record.class.name, record.to_ferret_doc

Aaf adds it's own to_doc method to your AR model, but since you don't
use AR in your external script, you'll have to implement your own - see
instance_methods.rb for how aaf does this.

Future versions of aaf might better support this scenario - there are
plans to decouple it from ActiveRecord so it can be used with non-AR
classes. But don't expect anything in this direction too soon ...


cheers,
Jens


-- 
Jens Krämer
http://www.jkraemer.net/ - Blog
http://www.omdb.org/     - The new free film database
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to