TitleIsbnPagesPrice
Kette, Jasinski und Preuss742434504860,00 €
Ruth GmbH756283721550,00 €
Schuhaj AG742530083780,00 €
Hornung-Paesler691046750790,00 €
Kuhlee OHG155810540290,00 €
Schramm-Lenfers491188185670,00 €
Lienshöft UG261054738300,00 €
Wolfarth Gruppe606237560580,00 €
Göckeritz KG190973975180,00 €
Seiders OHG884535943520,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