gaffneyc / sunspot-queue

Background search indexing using existing worker systems
MIT License
35 stars 37 forks source link

Tasks failing with "undefined method `params' for #<Account:0x007ffa6e6f6718>" #10

Closed wazoo closed 11 years ago

wazoo commented 11 years ago

When I try to run a task (in this case via Account.index) every single task fails with this, I have no idea why it is loading the controllers in my app to do this. The methods sort_column, fetch_people, and people that it is trying to run are all involved in fetching json for something else, is it trying to read json from the index action or something?

/Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/activemodel-3.2.12/lib/active_model/attribute_methods.rb:407:in method_missing' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/activerecord-3.2.12/lib/active_record/attribute_methods.rb:149:inmethod_missing' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/util.rb:241:in __proxy_method__' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/util.rb:236:inmethod_missing' /Users/wazoo/projects/serenity/app/controllers/people_controller.rb:241:in sort_column' /Users/wazoo/projects/serenity/app/controllers/people_controller.rb:222:infetch_people' /Users/wazoo/projects/serenity/app/controllers/people_controller.rb:207:in people' /Users/wazoo/projects/serenity/app/models/account.rb:66:inblock (2 levels) in class:Account' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/util.rb:208:in instance_eval' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/util.rb:208:ininstance_eval_with_context' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/util.rb:86:in instance_eval_or_call' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/data_extractor.rb:33:invalue_for' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/field_factory.rb:58:in populate_document' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/indexer.rb:95:inblock in prepare' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/indexer.rb:94:in each' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/indexer.rb:94:inprepare' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/indexer.rb:24:in block in add' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/indexer.rb:24:inmap' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/indexer.rb:24:in add' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/session.rb:91:inindex' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in index' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-1.3.3/lib/sunspot.rb:184:inindex' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot_rails-1.3.3/lib/sunspot/rails/searchable.rb:372:in solr_index' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-queue-0.10.0/lib/sunspot/queue/resque/index_job.rb:13:inblock in perform' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-queue-0.10.0/lib/sunspot/queue/helpers.rb:15:in without_proxy' /Users/wazoo/.rvm/gems/ruby-1.9.3-p362@serenity/gems/sunspot-queue-0.10.0/lib/sunspot/queue/resque/index_job.rb:12:inperform'

I have looked for everything that I could possibly think of to figure this error out but I cant find anything.

gaffneyc commented 11 years ago

@wazoo based on the stack trace I don't think this is an issue with sunspot-queue, I would take a look at app/models/account.rb line 66 as that's the first of your code that is being executed.

You might be able to debug with something like this from rails console:

include Sunspot::Queue::Helper

without_proxy do
  Account.find([id]).index
end
wazoo commented 11 years ago

Thats what I thought, but I wanted to start here since I can index successfully with foreground indexing.

I tried to include that module and I get initialized constant?

gem list | grep sunspot
sunspot (1.3.3)
sunspot-queue (0.10.0)
sunspot_rails (1.3.3)
sunspot_solr (1.3.3)

gem list | grep resque 
resque (1.23.0)
resque-loner (1.2.1)

rails (3.2.12)

ruby-1.9.3-p362

The line in that file is:

text :contracts do
    contracts.map {|c| c.contractnumber}
end

That is a relationship as defined in account.rb:

has_many :business_units
has_many :contracts,    through: :business_units

Thoughts? Again, thanks for the help, I have been pulling my hair out.

wazoo commented 11 years ago

Okay, just for your future debugging, I figured it out, solution here:

https://github.com/sunspot/sunspot/issues/368

gaffneyc commented 11 years ago

Glad you figured it out. :metal: