Newbie having problem with search function

Hi Guys ,

           I am a newbie to rails so forgive me if this has been

answered before. I am currently doing an inventory management project
on RoR and got 3 tables , goods , customers and staff. I used scaffold
to generate all of them.

           I just generated a new scaffold called search and I

need to search values from all 3 tables. i am using the steps from
this site ,

http://wiki.rubyonrails.org/rails/pages/HowToImplementSearch

The only change is from Person/people to Book/books .But I keep
getting this error

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each

Can someone help? The places where I put the codes are below ,

def search
query = params[:q]
@people = Person.find(:all, :conditions => [“name = ?”, query])
end

is in search_controller.rb

the codes for view are in view/search/index.rhtml and search.rhtml.
Thank you so much!!

regards
billy

billy am wrote:

You might have expected an instance of Array.

the codes for view are in view/search/index.rhtml and search.rhtml.
Thank you so much!!

regards
billy

Hi Billy,

Can you check for typos? As the message suggests, it seems that one of
the arrays you are evaluating in the view does not actually have any
data in it. Perhaps, you have a typo like @book instead of @books or
something in your view… would be worth checking, in my opinion.

Does Rails show you the code where the error occurs? Could you post
that?

Cheers
Mohit.

The case is closed :stuck_out_tongue: Thanks to Mohit for the help!

regards
billy