sunspot/sunspot — Issue #112: Issue with hits having something that is nil relating to the raw id
Author: tcocca
Created: 2011-10-21 18:08:37+00:00
State: open

I am getting the following error:

undefined method `[]' for nil:NilClass
On line #11 of app/views/admin/lead_searches/_results.html.erb

11: <%= sunspot_will_paginate(@leads.hits) %>

sunspot (1.2.1) lib/sunspot/search/hit.rb:30:in `initialize'
sunspot (1.2.1) lib/sunspot/search/abstract_search.rb:84:in `new'
sunspot (1.2.1) lib/sunspot/search/abstract_search.rb:84:in `hits'
sunspot (1.2.1) lib/sunspot/search/abstract_search.rb:83:in `map'
sunspot (1.2.1) lib/sunspot/search/abstract_search.rb:83:in `hits'
app/views/admin/lead_searches/_results.html.erb:11

sunspot_will_paginate is pretty simple ...

def sunspot_will_paginate(hits)
unless hits.blank?
will_paginate(
hits,
:renderer => "RemoteLinkRenderer",
:remote => {:before => "$('spinner').show();", :complete => "$('spinner').hide();"}
)
end
end

It just renders a ajax pagination list

What I don't understand is how something could be nil here:

https://github.com/sunspot/sunspot/blob/master/sunspot/lib/sunspot/search/hit.rb#L30

Any thoughts? It was fixed by re-indexing the records. What could have been nil?

~ Tom