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
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Pat Allan  
View profile  
 More options Aug 6 2010, 2:44 am
From: Pat Allan <p...@freelancing-gods.com>
Date: Fri, 6 Aug 2010 16:44:25 +1000
Local: Fri, Aug 6 2010 2:44 am
Subject: Re: [ts] Re: Indexing an instance method data
Hi Mike

I think it's before_validation... and you'd probably want something more like:

  before_validation :set_cached_rating

  def set_cached_rating
    self.cached_rating = rating
  end

This way the value is actually being stored in the database :)

--
Pat

On 06/08/2010, at 4:39 PM, 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>"

> Can anyone help me out.

> Thanks,
> Mike

> On Aug 5, 11:38 am, James Healy <ji...@deefa.com> wrote:
>> Mike Disuza wrote:
>>> For rating I am using "acts_as_a_rateable" plugin which is giving a
>>> rating by using "obj.rating" method.
>>> I know that Sphinx does not do indexing of the method.

>>> Can anyone have any idea how to solve this?

>> I'm not familiar with the acts_as_a_rateable plugin, but you probably
>> have 2 options:

>> * find out if the plugin stores the rating in your database somewhere
>>   and add that column to your index

>> * if the rating is purely calculated in ruby, you will have to add a
>>   model callback that caches the value in your database. I've described
>>   this technique a few times on stack overflow, check out [1]

>> -- James Healy <ji...@deefa.com>  Thu, 05 Aug 2010 16:37:45 +1000

>> [1]http://stackoverflow.com/questions/3391048/including-rails-activereco...

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.