Evaluating nil in an autocomplete? :o(

Can anyone help with the following? I’ve been trying to follow along
with the tutorial for making a real-time search box with Ajax
but have been hitting some snags along the way:

In the index view:

<%= observe_field ‘search’, :frequency => 0.5,
:update => ‘searchresults’, :url =>
{ :controller => ‘contacts’, :action=> ‘list’ },
:with => “‘search=’ + escape(value)” %>

In the contacts controller

def list
if @params[‘search’]
@contacts_pages, @contacts = paginate :contacts,
:order_by => ‘firstname’,
:conditions => [ ‘LOWER(firstname) LIKE ?’,
‘%’ + @params[‘search’].downcase + ‘%’ ],
:per_page => 20
@mark_term = @params[‘search’]
@contacts_pages, @contacts = paginate :contacts,
:order_by => ‘firstname’, :per_page => 20

And then finally in the list view.

<%= @mark_term ? highlight(contact.firstname, @mark_term) :
h(contact.firstname) %>

Everytime I run it, the searchresults layer updates to show a error that
isn’t that helpful:

NoMethodError in ContactsController#list

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.[]

Are you working in Rails 2.x? The old default pagination helper (used
in the “paginate :contacts” call) has been deprecated. That might
explain the NoMethodError. If this is the case you might just try to
get it working without pagination by calling Contact.find with the
appropriate parms.

On Jan 29, 6:27 pm, Neil H. [email protected]