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,b.name
,b.description,b.pages,b.isbn,b.created_at,b.updated_at]
               end
            end
          end
          send_data csv_data,
    :type => ''text/csv; charset=iso-8859-1;
header=present'',
    :disposition => "attachment;
filename=books"+datestamp+".csv"
          flash[:notice] = "Export complete!"
      end
    end
  end
Thanks in advance.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.