CSV - Error- Please help me

Hi all,

I have a books controller in which i have a list of all books displayed.

I want to have a csv download option.

The point is that i want csv download according to the pagination.

When i click on first page and click csv download i need to get only first 2 records(per page=>2)

When i click on the second page i want the csv file with next 2 records.

Please guide me where i went wrong.

Here is my controller:

def index

@books = Book.paginate(:all, :page=>params[:page], :per_page=>2)

datestamp = Date.today.strftime("%d%b%Y%H")

respond_to do |format|
format.html # index.html.erb
  format.xml  { render :xml => @books }
  format.csv do
    csv_data=FasterCSV.generate do |csv|
      csv << ["Serial", "Name","Description", "pages","isbn", "Created At", "Modified At"]
         @books.each do |b|
            csv << [[b.id](http://b.id),[b.name](http://b.name),b.description,b.pages,b.isbn,b.created_at,b.updated_at]
      send_data csv_data,
:type => 'text/csv; charset=iso-8859-1; header=present',
:disposition => "attachment; filename=books"+datestamp+".csv"
      flash[:notice] = "Export complete!"


Thanks in advance.

What exactly isn't working? Your subject line says "Error", but
there's no mention of *what* error. How about posting a stack trace of
the error, or at least describing what happens?

--Matt Jones