The reason is that when I comment out the define_index declarations in the models, that part of the code runs fine. Putting it back in, breaks it. That lead me to believe it's a thinking-sphinx issue
On Tuesday, September 4, 2012 8:02:29 AM UTC-4, complistic wrote: > > Hi Ahmed, > > What makes you think this is an thinking-sphinx error? I have seen similar > errors when upgrading an app from 3.0 to 3.1 without thinking-sphinx. > > I think it was to do with calling associations on empty ActiveRecord > result sets. > > What is the code that creates @person, and whats its current value? > The error makes me think the value of @person is nil or an Association > object (not a Person). > > If @person is indeed a Person, Whats the value of @person.current_friends? > > I hope I've given you a few new ideas. > > David Bennett > > > > On Tuesday, 4 September 2012 01:20:14 UTC+9:30, Daly wrote: >> >> Hello, >> >> I'm running thinking-sphinx 2.0.10 in a Rails 3.2 app. >> >> rvm --version >> rvm 1.14.12 (stable) by Wayne E. Seguin <[email protected]>, Michal >> Papis <[email protected]> [https://rvm.io/] >> >> ruby --version >> ruby 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:NilClass >> >> The offending line is: >> @friends = @person.current_friends.order('RAND()').limit(5) >> >> The association is: >> >> In person.rb: >> has_many :current_friends, :source => :friend, :through => :friends >> >> and 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 >> end >> >> >> In friend.rb: >> belongs_to :person >> belongs_to :friend, :class_name => 'Person', :foreign_key => >> "friend_id" >> validates_presence_of :person_id, :friend_id >> >> The 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 >> > -- 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/-/lAZymoitlGAJ. 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.
