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 <[email protected]>  Fri, 06 Aug 2010 16:42:23 +1000

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to