heithem nouira
2011-May-19 14:04 UTC
how can i index the sum of tow attributes with thinking sphinx ?
i have option model with this structure:
Class Option < ActiveRecord::Base
has_one :base_price, :class_name => "OptionPrice", :conditions
=>
{:base => true}
define_index do
indexes base_price.provider_price, :as => :p_base_price
indexes base_price.margin_price, :as => :m_base_price
indexes "SUM(p_base_price, m_base_price)", :as => :base_price
end
and in the controller i want to do :
@products = Option.search(params[:search], :conditions =>{:base_price
=> 15 } ,
:page => params[:page], :per_page => 2)
this is a wrong solution of course but i think any one can understand
what i want to do : searching products having base_price = 15
(base_price = provider_price + margin_price, which are OptionPrice
attributes)
How can i solve this issue , i''m using thinking_sphinx 2.0.3 and RAILS
3
Best Regards
thanks
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.