认为 sphinx 索引很好,并且查找在我的属性上效果很好。但是,我保存模型实例的尝试崩溃了。
class Location < ActiveRecord::Base
has_many :operation_intervals_locations
has_many :operation_intervals, :through => :operation_intervals_locations
define_index "location" do
# indexes here...
# tried this syntax
has operation_intervals(:start_int), :type => :integer
has operation_intervals(:end_int), :type => :integer
has operation_intervals(:days_int), :type => :integer
# and this one
has operation_intervals.start_int, :type => :integer
has operation_intervals.end_int, :type => :integer
has operation_intervals.days_int, :type => :integer
end
end
class OperationInterval < ActiveRecord::Base
attr_accessible :start_int, :end_int, :days_int
end
每当我执行以下操作时:
Location.search("foo") # get the search initialized
l = Location.first
l.name = "bar"
l.save(:validate => false)
我得到以下信息:
# joining is working just fine
OperationInterval Load (0.3ms) SELECT `operation_intervals`.* FROM `operation_intervals` INNER JOIN `operation_intervals_locations` ON `operation_intervals`.`id` = `operation_intervals_locations`.`operation_interval_id` WHERE `operation_intervals_locations`.`location_id` = 1
# here's where I'm getting my crash
NoMethodError: undefined method `end_int' for #<ActiveRecord::Relation:0xe048450>
from /usr/local/rvm/gems/ruby-1.9.3-p194@rails326/gems/activerecord-3.2.6/lib/active_record/relation/delegation.rb:45:in `method_missing'
编辑:我正在使用延迟的增量 - 延迟的工作。我认为问题正在发生,因为thinking_sphinx 正试图将工作推到队列中。