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 (http://wiki.rubyonrails.org/rails/pages/How+to+make+a+real-time+search+box+with+the+Ajax+helpers), but have been hitting some snags along the way:

In the index view: <input id="search" name="search" type="text" value=""> <%= observe_field 'search', :frequency => 0.5,          :update => 'searchresults', :url =>          { :controller => 'contacts', :action=> 'list' },          :with => "'search=' + escape(value)" %>

<div id="searchresults">

</div>

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']     render_without_layout   else     @contacts_pages, @contacts = paginate :contacts,       :order_by => 'firstname', :per_page => 20   end end

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.