Prevent indexing depending on variable

Hi guys, I’m using attachment_fu on my site to allow users to upload
pictrues. Pictures can be set to only allow friends to view them.

The problem I’m having is ferret is indexing the images along with their
thumbnails which means I end up with a lot of broken images in the
search. Also it’s indexing images whose privacy is set to 1 (friends
only).

How could I go about only indexing the images with no parent_id (main
image, not it’s thumbnails) and privacy set to 0 (viewable by all)?

On Fri, Sep 28, 2007 at 12:10:51PM +0200, Jim N. wrote:

Hi guys, I’m using attachment_fu on my site to allow users to upload
pictrues. Pictures can be set to only allow friends to view them.

The problem I’m having is ferret is indexing the images along with their
thumbnails which means I end up with a lot of broken images in the
search. Also it’s indexing images whose privacy is set to 1 (friends
only).

How could I go about only indexing the images with no parent_id (main
image, not it’s thumbnails) and privacy set to 0 (viewable by all)?

override the ferret_enabled? instance method in your model class.

Cheers,
Jens


Jens Krämer
http://www.jkraemer.net/ - Blog
http://www.omdb.org/ - The new free film database

Thanks, Jens.

How would I go about doing that?

something like:

class MyModel < ActiveRecord::Base
def ferret_enabled?
self.secret == false
end
end

John.

On Fri, 2007-09-28 at 13:54 +0200, Jim N. wrote:

Thanks, Jens.

How would I go about doing that?

http://www.brightbox.co.uk - UK Rails Xen Hosting

Would something like this work:

def ferret_enabled?
self.privacy ? false : self.parent_id ? false : true
end

Jim N. wrote:

Would something like this work:

def ferret_enabled?
self.privacy ? false : self.parent_id ? false : true
end

Just tried it. Seems to work great with new images. How do I go about
rebuilding the index of the current images?

On Sat, Sep 29, 2007 at 12:20:08PM +0200, Jim N. wrote:

Jim N. wrote:

Would something like this work:

def ferret_enabled?
self.privacy ? false : self.parent_id ? false : true
end

Just tried it. Seems to work great with new images. How do I go about
rebuilding the index of the current images?

Model.rebuild_index


Jens Krämer
http://www.jkraemer.net/ - Blog
http://www.omdb.org/ - The new free film database

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs