friends, thanks a lot for all the help offererd so far.....however, i
am getting the same error, even after following the instructions:
undefined method `paginate' for Person(id: integer, name: string,
address: text):Class
RAILS_ROOT: C:/ruby/contact
Application Trace | Framework Trace | Full Trace
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
base.rb:1532:in `method_missing'
app/models/person.rb:7:in `search'
app/controllers/people_controller.rb:5:in `index'
this is the pagination code in controller:
def index
@people = Person.search(params[:search], params[:page])
end
this is the code in the model i.e person.rb
def self.search(search, page)
paginate :per_page => 5, :page => page,
:conditions => ['name like ?', "%#{search}%"],
:order => 'name'
end
and this is the code in the index.html.erb:
<h1>Listing people</h1>
<table>
<tr>
<th>Name</th>
<th>Address</th>
</tr>
<% for person in @people %>
<tr>
<td><%=h person.name %></td>
<td><%=h person.address %></td>
<td><%= link_to 'Show', person %></td>
<td><%= link_to 'Edit', edit_person_path(person) %></td>
<td><%= link_to 'Destroy', person, :confirm => 'Are you
sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<!-- products/index.rhtml -->
<%= will_paginate @people %>
<%= link_to 'New person', new_person_path %>
Guys, does anyone know what mistake i might have made? please do
help