print multiple pages

I have a nice Product model, which has a lot of fields, the controller
has a Index and Show method to list the products and show the details
both with a print procedure using windows.print() and a print format
css which makes the printouts look good. Happy days! Until I get a
request that the sales guys want a "print-all" function, that prints
out the 40 or so product details (a page a product) using the Show
product format, so they dont have to move through each product
printing them individually; the resulting print-out makes a good
catalogue which they can then easily update.

I am only just mastering RAILS and dont have problems with CRUD but I
think this is somewaht out of my depth.

Can anyone help?

I haven't done anything with formatting output for print, so take this
with a grain of salt, but methinks this ought to work:

- First, I assume you have a button or link or whatever that goes to
some URL that's supposed to give them a printable catalog, and that we
can control this URL so as to make it point to a given action of a
given controller.

- In the controller, load up an array, let's call it @products, with
all the products, including all the details that go into the catalog.
You can use the :include option on the search to make sure that
they're grabbed off any associated objects. You put that logic either
in the controller itself, or better, in the model, exposing some call
like Product.get_all_for_catalog. (If you want to print multiple
types of catalog, you could even have that take some filtering args,
in which case the "all" part might be misleading, and maybe some
format identification, which could determine which details to
include.) So your controller might contain something like "@products
= Product.get_for_catalog({ :which => :all, :format => :print })".

- In the view, output whatever front material you want (cover, ToC,
etc.), iterate over @products (outputting the description), and
finally output whatever back material you want (order form, index,
back cover, etc.). You could use the existing HTML description
output, or alternately put it all in a PDF document with a library
like Prawn. If you want, you can force a page break between each, or
use some kind of pagination helper like will_paginate. (Depends how
long your product descriptions are.) Iterating over it might look
something like:

  <% @products.each do |prod| %>
    <%= render_partial product_print, prod %>
  <% end %>

Be careful which lines you have the = sign on; that's what tells ERb
to actually show it, not just do it.