Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何测试太阳黑子搜索结果或命中率_Ruby On Rails_Sunspot_Kaminari - Fatal编程技术网

Ruby on rails 如何测试太阳黑子搜索结果或命中率

Ruby on rails 如何测试太阳黑子搜索结果或命中率,ruby-on-rails,sunspot,kaminari,Ruby On Rails,Sunspot,Kaminari,我在测试使用太阳黑子搜索的索引页时出错 *** NoMethodError Exception: undefined method `[]' for nil:NilClass 我写的代码是 @object.hits 此错误也发生在 @object.results 我试过@object.present@object.blank@object.nil 我使用kaminari对结果进行分页 = paginate(@object.hits) 通过在我的测试用例之前添加Model.reindex解

我在测试使用太阳黑子搜索的索引页时出错

*** NoMethodError Exception: undefined method `[]' for nil:NilClass
我写的代码是

@object.hits
此错误也发生在

@object.results
我试过@object.present@object.blank@object.nil

我使用kaminari对结果进行分页

= paginate(@object.hits)

通过在我的测试用例之前添加Model.reindex解决了这个问题

 setup do
   Model.reindex
 end