TitleIsbnPagesPrice
Haaf GmbH & Co. KG420613243190,00 €
Bouschen KG591563718620,00 €
Heinke KG976196774670,00 €
Mikitenko Gruppe665408668320,00 €
Orth, Pusch und Strunz679754103650,00 €
Dylus-Friedenberg516866602850,00 €
Tietze, Cleve und Deerberg941964546170,00 €
Sauerland-Plauk350377759710,00 €
Schuff, Banse und Schwidde671575115500,00 €
Vogelgsang, Huckestein und Sammert900405330870,00 €

Download as CSV

HAML:
= table_go_for @books, Book, :table_html => {:class => 'table table-striped table-hover table-bordered'} do |t|
  - t.column :title
  - t.column :isbn
  - t.column :pages
  - t.column :price, :as => :currency
= link_to('Download as CSV', books_path(format: :csv), class: 'btn btn-primary')
Controller:
# frozen_string_literal: true

class BooksController < ApplicationController
  def index
    @books = Book.paginate(pagination_defaults)

    respond_to do |format|
      format.html
      format.csv do
        send_data(render_to_string(template: 'books/index', format: :csv),
                  type: 'text/csv; charset=utf-8; header=present',
                  filename: 'books.csv',
                  disposition: 'attachment')
      end
    end
  end
end