Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Indexing an instance method data

Received: by 10.150.73.3 with SMTP id v3mr6992390yba.16.1281076967065;
        Thu, 05 Aug 2010 23:42:47 -0700 (PDT)
X-BeenThere: thinking-sphinx@googlegroups.com
Received: by 10.150.48.5 with SMTP id v5ls1401220ybv.6.p; Thu, 05 Aug 2010 
	23:42:46 -0700 (PDT)
Received: by 10.151.50.14 with SMTP id c14mr7137844ybk.6.1281076965807;
        Thu, 05 Aug 2010 23:42:45 -0700 (PDT)
Received: by 10.151.50.14 with SMTP id c14mr7137843ybk.6.1281076965769;
        Thu, 05 Aug 2010 23:42:45 -0700 (PDT)
Return-Path: <ji...@deefa.com>
Received: from gir.yob.id.au (gir.yob.id.au [207.210.245.140])
        by gmr-mx.google.com with ESMTP id d3si904914ybi.5.2010.08.05.23.42.45;
        Thu, 05 Aug 2010 23:42:45 -0700 (PDT)
Received-SPF: pass (google.com: domain of ji...@deefa.com designates 207.210.245.140 as permitted sender) client-ip=207.210.245.140;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ji...@deefa.com designates 207.210.245.140 as permitted sender) smtp.mail=ji...@deefa.com
Received: by gir.yob.id.au (Postfix, from userid 1000)
	id 8A7354078D; Fri,  6 Aug 2010 16:42:44 +1000 (EST)
Date: Fri, 6 Aug 2010 16:42:44 +1000
From: James Healy <ji...@deefa.com>
To: thinking-sphinx@googlegroups.com
Subject: Re: [ts] Re: Indexing an instance method data
Message-ID: <20100806064244.GA8971@deefa.com>
References: <60ca5846-b1ff-40fd-ba5c-cb377340c583@w15g2000pro.googlegroups.com>
 <20100805063821.GS8971@deefa.com>
 <cf2ddb68-cd16-438a-a615-7dd561933578@p11g2000prf.googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
In-Reply-To: <cf2ddb68-cd16-438a-a615-7dd561933578@p11g2000prf.googlegroups.com>
User-Agent: Mutt/1.5.20 (2009-06-14)

Mike Disuza wrote:
> Hi,
> I am trying your solution like this
> My model is like this:-
> "
> before_validate :cache_rating
> define_index do
>     indexes :name,:sortable => true
>     indexes cached_rating, :as=>:property_rating
>  end
> def cache_rating
>     self.rating
>  end
> "
> Whenever I am trying to rebuild the indexing using "rake ts:rebuild",
> I am getting error "undefined method `before_validate' for #<Class:
> 0xb6cce9c4>"

My bad, that answer was untested. before_validate should be
before_validation.

Also, you're cache_rating method should look like:

    def cache_rating
      self.cached_rating = self.rating
    end

Make sure your model has a cached_rating column in the DB.

-- James Healy <ji...@deefa.com>  Fri, 06 Aug 2010 16:42:23 +1000