# Undefined method \`sphinx\_facets' for nil:NilClass

**URL:** <https://www.ruby-forum.com/t/undefined-method-sphinx-facets-for-nil-nilclass/183299>\
**Category:** Rails\
**Created:** [February 11, 2010, 12:49pm UTC](https://www.ruby-forum.com/t/undefined-method-sphinx-facets-for-nil-nilclass/183299 "2010-02-11T12:49:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rabia\_Akhtar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ad7895/32.png) [@Rabia\_Akhtar](https://www.ruby-forum.com/u/Rabia_Akhtar)\
**Post date:** [February 11, 2010, 12:49pm UTC](https://www.ruby-forum.com/t/undefined-method-sphinx-facets-for-nil-nilclass/183299/1 "2010-02-11T12:49:48Z")

</div>

I am getting  
A NoMethodError occurred in main#search:

undefined method `sphinx_facets' for nil:NilClass [RAILS_ROOT]/vendor/plugins/ thinking-sphinx/lib/thinking_sphinx/facet_search.rb:131:in`facet\_from\_object’

Its occur in special scenerio…  
Can any body tell me when and how to resolve this exception??

Thanks

---

<div class="post-metadata">

**Author:** ![Rabia\_Akhtar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ad7895/32.png) [@Rabia\_Akhtar](https://www.ruby-forum.com/u/Rabia_Akhtar)\
**Post date:** [February 11, 2010, 2:56pm UTC](https://www.ruby-forum.com/t/undefined-method-sphinx-facets-for-nil-nilclass/183299/2 "2010-02-11T14:56:51Z")

</div>

On 11 Feb 2010, at 12:48, Rabia Akhtar wrote:

> Can any body tell me when and how to resolve this exception??

1. Make sure you don’t get nil values
2. If nil values can’t be avoided, check for nil and don’t call  
sphinx\_facets on it.

Best regards

Peter De Berdt
