TitleIsbnPagesPrice
Lepthin OHG821095886600,00 €
Leitheim, Dreier und Steffen855606453120,00 €
Obermaier GmbH591345067870,00 €
Goldkamp, Mehlhorn und Sagonas909105555620,00 €
Spank GmbH615384245140,00 €
Boxhammer, Göckeritz und Raubuch324612266550,00 €
Schelk UG862582679660,00 €
Blank UG364090353320,00 €
Rohländer, Waldmann und Drechsler314790403110,00 €
Storl-Ehmann171389149660,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