I have a Business model that has many ratings (in a separate table).
The average rating for a business is calculated as shown below:
class Business < ActiveRecord::Base
has_many :ratings
def average_rating
ratings.average(:value) # value is a field in Rating model
end
end
I would like to index the average rating for businesses via sphinx. I
tried the following and got an error:
has "AVG(ratings.value)", :as => :rating, :type => :float
Can someone please let me know how to approach this problem?
Thank you in advance.
-- Thuva Tharma
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---