TitleIsbnPagesPrice
Ahlke-Drees653898693620,00 €
Thöne OHG775237183660,00 €
Heist OHG686647858850,00 €
Greithanner AG395344794660,00 €
Gutjahr, Gutschank und Greschner107177209390,00 €
Burger, Riethmüller und Mau913263125640,00 €
Schönebeck, Plotzitzka und Salow693268887900,00 €
Berner-Evers684879540750,00 €
Schwartz-Kruschinski478114118210,00 €
Kolb, Demut und Schildhauer586210921780,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