table_print icon indicating copy to clipboard operation
table_print copied to clipboard

How would I configure the default tp in a Rails initializer?

Open benlieb opened this issue 2 years ago • 1 comments

Using this in a rails app. How would I configure the default tp in a Rails initializer?

For example, I'd like to make headers always lowercase via:

tp.set :capitalize_headers, false

But I don't want to have to do that every time. Do I need to make my own wrapper?

benlieb avatar Oct 13 '21 18:10 benlieb

Came up with this:

Toco::Application.configure do
  config.after_initialize do
    TablePrintConfigurator.set_defaults
  end
end
class TablePrintConfigurator
  def self.set_defaults
    tp.set Transaction, :id, :description, :amount, :total_cost, :active, :charge_id, :charge_type, :invoice_id, :multiplier, :transaction_type_id, :trx_date, :created_at, :updated_at
    ...
  end
end

benlieb avatar Mar 30 '22 18:03 benlieb