TitleIsbnPagesPrice
Jung-Cors392255012780,00 €
Streck, Mathes und Schmidtchen951675384610,00 €
Buchrucker, Jeorga und Streit742924509760,00 €
Hannecker-Koha452907264560,00 €
Goldfuss, Geisler und Birkemeyer587667014130,00 €
Brömme-Höcke911319587320,00 €
Bringmann OHG594302480690,00 €
Beushausen, Ringer und Hirsch600541477970,00 €
Mensah-Barr491255979230,00 €
Krämer GmbH352070544140,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