Forum: Ferret find conditions in more_like_this

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
66b8ecb6f2cd9f32b657af75c5feebba?d=identicon&s=25 Jason Hines (Guest)
on 2007-02-16 19:04
Hello.

I'm trying to use acts_as_ferret to index with set conditions.

Ideally I could do something like:

 acts_as_ferret :fields => [ :title, :body ],
                :conditions => ["enabled = 1"]

But would settle for being able to do:

 @similiar_blogs = @blog.more_like_this :field_names => [ :title, :body
], :conditions => "enabled=1"

What is the best way of accomplishing this with using more_like_this, or
even better -- applying these conditions to the model to be indexed
globally.

Thanks in advance for any advice or suggestions.
C9dd93aa135988cabf9183d3210665ca?d=identicon&s=25 Jens Kraemer (Guest)
on 2007-02-19 10:12
(Received via mailing list)
On Fri, Feb 16, 2007 at 07:04:45PM +0100, Jason Hines wrote:
> But would settle for being able to do:
>
>  @similiar_blogs = @blog.more_like_this :field_names => [ :title, :body
> ], :conditions => "enabled=1"
>
> What is the best way of accomplishing this with using more_like_this, or
> even better -- applying these conditions to the model to be indexed
> globally.

you could override the ferret_enabled? instance method to only return
true if your condition is met.

cheers,
Jens

--
Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
kraemer@webit.de | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
This topic is locked and can not be replied to.