# NoMethodError: You have a nil object when you didn't expect

**URL:** <https://www.ruby-forum.com/t/nomethoderror-you-have-a-nil-object-when-you-didnt-expect/189298>\
**Category:** Rails\
**Created:** [May 28, 2010, 9:20am UTC](https://www.ruby-forum.com/t/nomethoderror-you-have-a-nil-object-when-you-didnt-expect/189298 "2010-05-28T09:20:32Z")\
**Posts on this page:** 1\
**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, 9:20am UTC](https://www.ruby-forum.com/t/nomethoderror-you-have-a-nil-object-when-you-didnt-expect/189298/1 "2010-05-28T09:20:32Z")

</div>

Hi,

I have tried to use searchlogic in my application…  
in def index,  
@search = AccounDetail.search(params[:search])  
@account\_details = @search.all

In index.rhtml  
\<%form\_for @search do |f|%\>

\<%=f.label :name\_like,"Name"%\> \<%=f.text\_field :name\_like%\> \<%=submit\_tag :Search,:name=\>nil%\>

\<%end%\>

I didn’t get any search result…  
i tried it with ruby script/console.  
when i call @search.all, i got “NoMethodError: You have a nil object  
when you didn’t expect”

example

> > search=AccountDetail.search(:name\_like\_any=\>“xx”)  
> > search.all

give me a suggestion to solve this problem
