I'm trying to follow the Agile Web Development example, and do
I have a model SearchTerm, and another model Listing
class SearchTerm < ActiveRecord::Base
In my admin controller, if I do this
@search_term = SearchTerm.find(params[:id])
Then, with a given id related to a search term, in a view, I can
iterate through listings that are related to a given search term id,
<% @search_term.listings.undeleted.each do |listing| %>
<div><%= listing.title %></div>
<% end %>
But I can't figure out how to paginate these listings. The Agile Web
Development example uses one table with no parent table. If I do this
in my admin controller:
@listing_pages, @listings = paginate :listings, :per_page => 25
I can have a list.rhtml view, with this
<% for listing in @listings %>
<%= listing.title %>
<% end %>
Then if I navigate to http://0.0.0.0:3000/admin/list
I certainly get a paginated list of 25 listings, but of course they
are not related to a given search term id, in my search_terms table.
It just starts with the first listing in the listings table, and gives
the first 25.
How do I hook up pagination to the parent table?