スフィンクスのインデックスをうまく考えると、ルックアップは私の属性でうまく機能します。ただし、モデルインスタンスを保存しようとするとクラッシュします。
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がジョブをキューにプッシュしようとしているときに、問題が発生していると思います。