Question

I am getting an error while testing an index page which uses sunspot search.

*** NoMethodError Exception: undefined method `[]' for nil:NilClass

The code which i wrote is

@object.hits

This error also occurs with

@object.results

I have tried @object.present? , @object.blank? , @object.nil?

I have used kaminari to paginate my results

= paginate(@object.hits)
Was it helpful?

Solution

Solved by adding Model.reindex before my test case.

 setup do
   Model.reindex
 end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top