Hello,I'm running thinking-sphinx 2.0.10 in a Rails 3.2 app.rvm --versionrvm 1.14.12 (stable) by Wayne E. Seguin <waynee...@gmail.com>, Michal Papis <mpa...@gmail.com> [https://rvm.io/]ruby --versionruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.2]This used to be a rails 2.3 app that I'm converting. It always breaks at the exact same location with:   undefined method `association_class' for nil:NilClassThe offending line is:  @friends = @person.current_friends.order('RAND()').limit(5)The association is:In person.rb:  has_many :current_friends, :source => :friend, :through => :friendsand the sphinx method in person.rb is:  define_index do   indexes :user_name   indexes :id, :as => :id   indexes :email, :as => :email   indexes :account_verified#, :as => :account_verified   set_property :delta => false  endIn friend.rb:  belongs_to :person  belongs_to :friend, :class_name => 'Person', :foreign_key => "friend_id"  validates_presence_of :person_id, :friend_idThe closes thing I could find that matches my issue is: https://github.com/pat/thinking-sphinx/issues/310, I did put the define index after all the declarations. I'm sure it's ts because when I comment out all define_index methods in the code, it works fine.This has been hounding me for a long time now.Thanks for your help,Ahmed
Can you provide the full stack trace of the error? It might provide some clues as to how Thinking Sphinx is getting in the way.
--
Pat
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/rCxKBnWrdrAJ.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
/gems/activerecord-3.2.6/lib/active_record/associations.rb:157:in `association'
/gems/activerecord-3.2.6/lib/active_record/associations/builder/association.rb:44:in `block in define_readers'
app/controllers/account_controller.rb:58:in `index'
/gems/actionpack-3.2.6/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/gems/actionpack-3.2.6/lib/abstract_controller/base.rb:167:in `process_action'
/gems/actionpack-3.2.6/lib/action_controller/metal/rendering.rb:10:in `process_action'
/gems/actionpack-3.2.6/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:513:in `_run__1786129847638205132__process_action__213430523744088085__callbacks'
/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:405:in `__run_callback'
/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:81:in `run_callbacks'
/gems/actionpack-3.2.6/lib/abstract_controller/callbacks.rb:17:in `process_action'
/gems/actionpack-3.2.6/lib/action_controller/metal/rescue.rb:29:in `process_action'
/gems/actionpack-3.2.6/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/gems/activesupport-3.2.6/lib/active_support/notifications.rb:123:in `block in instrument'
/gems/activesupport-3.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/gems/activesupport-3.2.6/lib/active_support/notifications.rb:123:in `instrument'
/gems/actionpack-3.2.6/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/gems/actionpack-3.2.6/lib/action_controller/metal/params_wrapper.rb:206:in `process_action'
/gems/activerecord-3.2.6/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/gems/newrelic_rpm-3.4.1/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:34:in `block in process_action'
/gems/newrelic_rpm-3.4.1/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:262:in `block in perform_action_with_newrelic_trace'
/gems/newrelic_rpm-3.4.1/lib/new_relic/agent/method_tracer.rb:242:in `trace_execution_scoped'
/gems/newrelic_rpm-3.4.1/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:257:in `perform_action_with_newrelic_trace'
/gems/newrelic_rpm-3.4.1/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:33:in `process_action'
/gems/actionpack-3.2.6/lib/abstract_controller/base.rb:121:in `process'
/gems/actionpack-3.2.6/lib/abstract_controller/rendering.rb:45:in `process'
/gems/actionpack-3.2.6/lib/action_controller/metal.rb:203:in `dispatch'
/gems/actionpack-3.2.6/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/gems/actionpack-3.2.6/lib/action_controller/metal.rb:246:in `block in action'
/gems/actionpack-3.2.6/lib/action_dispatch/routing/route_set.rb:73:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/gems/actionpack-3.2.6/lib/action_dispatch/routing/route_set.rb:36:in `call'
/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/routing/route_set.rb:600:in `call'
/gems/oink-0.9.3/lib/oink/middleware.rb:17:in `call'
/gems/newrelic_rpm-3.4.1/lib/new_relic/rack/browser_monitoring.rb:12:in `call'
/gems/newrelic_rpm-3.4.1/lib/new_relic/rack/developer_mode.rb:24:in `call'
/gems/mongoid-3.0.5/lib/rack/mongoid/middleware/identity_map.rb:33:in `block in call'
/gems/mongoid-3.0.5/lib/mongoid/unit_of_work.rb:39:in `unit_of_work'
/gems/mongoid-3.0.5/lib/rack/mongoid/middleware/identity_map.rb:33:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/gems/rack-1.4.1/lib/rack/etag.rb:23:in `call'
/gems/rack-1.4.1/lib/rack/conditionalget.rb:25:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/middleware/head.rb:14:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/middleware/flash.rb:242:in `call'
/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/middleware/cookies.rb:338:in `call'
/gems/activerecord-3.2.6/lib/active_record/query_cache.rb:64:in `call'
/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:405:in `_run__3765126766932519170__call__2902207070006020771__callbacks'
/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:405:in `__run_callback'
/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:81:in `run_callbacks'
/gems/actionpack-3.2.6/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/middleware/reloader.rb:65:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/gems/railties-3.2.6/lib/rails/rack/logger.rb:26:in `call_app'
/gems/railties-3.2.6/lib/rails/rack/logger.rb:16:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
/gems/activesupport-3.2.6/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
/gems/actionpack-3.2.6/lib/action_dispatch/middleware/static.rb:62:in `call'
/gems/airbrake-3.1.2/lib/airbrake/rack.rb:42:in `call'
/gems/airbrake-3.1.2/lib/airbrake/user_informer.rb:12:in `call'
/gems/railties-3.2.6/lib/rails/engine.rb:479:in `call'
/gems/railties-3.2.6/lib/rails/application.rb:220:in `call'
/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
/gems/railties-3.2.6/lib/rails/rack/log_tailer.rb:17:in `call'
/gems/thin-1.4.1/lib/thin/connection.rb:80:in `block in pre_process'
/gems/thin-1.4.1/lib/thin/connection.rb:78:in `catch'
/gems/thin-1.4.1/lib/thin/connection.rb:78:in `pre_process'
/gems/thin-1.4.1/lib/thin/connection.rb:53:in `process'
/gems/thin-1.4.1/lib/thin/connection.rb:38:in `receive_data'
/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
/gems/thin-1.4.1/lib/thin/backends/base.rb:63:in `start'
/gems/thin-1.4.1/lib/thin/server.rb:159:in `start'
/gems/rack-1.4.1/lib/rack/handler/thin.rb:13:in `run'
/gems/rack-1.4.1/lib/rack/server.rb:265:in `start'
/gems/railties-3.2.6/lib/rails/commands/server.rb:70:in `start'
/gems/railties-3.2.6/lib/rails/commands.rb:55:in `block in '
/gems/railties-3.2.6/lib/rails/commands.rb:50:in `tap'
/gems/railties-3.2.6/lib/rails/commands.rb:50:in `'
script/rails:6:in `require'
script/rails:6:in `'Also, if it's possible, I'd be keen to reproduce this locally. Is getting access to your project's source an option? Or would you be able to create a sample app that also has this issue?
--
Pat
>>>>> 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 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 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 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.
To be honest, I'm not sure I can get much further without some code in front of me. If you can create a basic Rails application that reproduces the issue and send that to me, that'd be fantastic.
Most people aren't seeing this issue, so getting it fixed is no simple matter.
That said, what's the define_index block in your review model?
--
Pat
> >>>>> To post to this group, send email to thinkin...@googlegroups.com.
> >>>>> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> >>>>> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> >>>> To post to this group, send email to thinkin...@googlegroups.com.
> >>>> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> >>>> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
> >>>>
> >>>
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> >>> To post to this group, send email to thinkin...@googlegroups.com.
> >>> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> >>> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
> >>
> >>
> >>
> >> --
> >> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> >> To post to this group, send email to thinkin...@googlegroups.com.
> >> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> >> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
> >>
> >
>
>
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/jysKxBztSEIJ.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
On 05/12/2012, at 12:38 AM, Henrik Nyh wrote:
> We're looking into this issue as well. We haven't gotten to the bottom of it yet, but we've noticed some possibly interesting facts.
>
> We have reduced the issue to something like
>
> class Item < ActiveRecord::Base
> define_index do
> end
> has_one :my_association
> end
>
> class SubItem < Item
> end
>
> When running some tests with spork (but not without) that create an Item, we will get
>
> undefined method `association_class' for nil:NilClass
>
> when the factory tries to use `my_association`.
>
> We can unbreak it by duplicating "has_one :my_association" in the SubItem class.
>
> We can also unbreak it by moving the association in the Item class above "define_index do; end".
>
> Our current theory is that we hit "define_index", Thinking Sphinx does something with associations to be able to do its "index foo.bar" association magic, and that causes Item not to define the association when it should.
>
> Just sharing this to give Pat (and possibly others) something to go on if we don't come any further, and before I forget what we've found :)
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/eLkToyoNhxMJ.