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 Hoyne
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> 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+searc...),
> 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.[]
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---