# Got nil error when i call 'all' in searchlogic

**URL:** <https://www.ruby-forum.com/t/got-nil-error-when-i-call-all-in-searchlogic/189315>\
**Category:** Rails\
**Created:** [May 28, 2010, 4:43pm UTC](https://www.ruby-forum.com/t/got-nil-error-when-i-call-all-in-searchlogic/189315 "2010-05-28T16:43:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmanivannancse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@jmanivannancse](https://www.ruby-forum.com/u/jmanivannancse)\
**Post date:** [May 28, 2010, 4:43pm UTC](https://www.ruby-forum.com/t/got-nil-error-when-i-call-all-in-searchlogic/189315/1 "2010-05-28T16:43:40Z")

</div>

Hi,

```
 I have install searchlogic then tried in ruby script/console

```

search=BankingDetail.search(:name\_like\_all=\>“man”)  
search.all

i got error when i call ‘all’ method

NoMethodError: You have a nil object when you didn’t expect it!  
You might have expected an instance of ActiveRecord::Base.  
The error occurred while evaluating nil.[]

---

<div class="post-metadata">

**Author:** ![jmanivannancse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@jmanivannancse](https://www.ruby-forum.com/u/jmanivannancse)\
**Post date:** [May 28, 2010, 5:56pm UTC](https://www.ruby-forum.com/t/got-nil-error-when-i-call-all-in-searchlogic/189315/2 "2010-05-28T17:56:51Z")

</div>

On Fri, May 28, 2010 at 7:42 AM, Manivannan J [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> I have install searchlogic then tried in ruby script/console
> 
> ```
> 
> search=BankingDetail.search(:name\_like\_all=\>“man”)  
> search.all
> 
> i got error when i call ‘all’ method
> 
> NoMethodError: You have a nil object when you didn’t expect it!  
> You might have expected an instance of ActiveRecord::Base.  
> The error occurred while evaluating nil.[]

So your search returned no results – that’s a predictable outcome.

Rescue it and deal with it.

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![jmanivannancse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@jmanivannancse](https://www.ruby-forum.com/u/jmanivannancse)\
**Post date:** [May 29, 2010, 6:45am UTC](https://www.ruby-forum.com/t/got-nil-error-when-i-call-all-in-searchlogic/189315/3 "2010-05-29T06:45:18Z")

</div>

Manivannanj J. wrote:

> Hassan S. wrote:
> 
> > On Fri, May 28, 2010 at 7:42 AM, Manivannan J [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > wrote:
> > 
> > > ï¿½ ï¿½ I have install searchlogic then tried in ruby script/console
> > > 
> > > search=BankingDetail.search(:name\_like\_all=\>“man”)  
> > > search.all
> > > 
> > > i got error when i call ‘all’ method
> > > 
> > > NoMethodError: You have a nil object when you didn’t expect it!  
> > > You might have expected an instance of ActiveRecord::Base.  
> > > The error occurred while evaluating nil.[]
> > 
> > So your search returned no results – that’s a predictable outcome.
> > 
> > Rescue it and deal with it.
> > 
> > –  
> > Hassan S. ------------------------ removed\_email\_address@domain.invalid  
> > twitter: @hassan

Its not working by the following  
search=BankingDetail.search(:name\_like\_all=\>“man”)  
search.all

---

<div class="post-metadata">

**Author:** ![jmanivannancse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@jmanivannancse](https://www.ruby-forum.com/u/jmanivannancse)\
**Post date:** [May 29, 2010, 6:39am UTC](https://www.ruby-forum.com/t/got-nil-error-when-i-call-all-in-searchlogic/189315/4 "2010-05-29T06:39:38Z")

</div>

Hassan S. wrote:

> On Fri, May 28, 2010 at 7:42 AM, Manivannan J [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > ï¿½ ï¿½ I have install searchlogic then tried in ruby script/console
> > 
> > search=BankingDetail.search(:name\_like\_all=\>“man”)  
> > search.all
> > 
> > i got error when i call ‘all’ method
> > 
> > NoMethodError: You have a nil object when you didn’t expect it!  
> > You might have expected an instance of ActiveRecord::Base.  
> > The error occurred while evaluating nil.[]
> 
> So your search returned no results – that’s a predictable outcome.
> 
> Rescue it and deal with it.
> 
> –  
> Hassan S. ------------------------ removed\_email\_address@domain.invalid  
> twitter: @hassan

But i got result when i tried the following

BankingDetail.name\_like\_all(“man”).all  
=\> [#\<BankingDetail id: 1, name: “man”, created\_at: nil, updated\_at:  
nil, username: nil, age: 2\>, #\<BankingDetail id: 2, name: “kamanl”,  
created\_at: nil, updated\_at: nil, username: nil, age: 1\>]

“all” method is not working when i assigned result to search variable  
then  
called the method search.all

I have spend nearly i day but i could n’t solved this… Help me to  
resolve this
