8000 How would I configure the default tp in a Rails initializer? · Issue #90 · arches/table_print · GitHub
[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
benlieb opened this issue Oct 13, 2021 · 1 comment
Open

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

benlieb opened this issue Oct 13, 2021 · 1 comment

Comments

@benlieb
Copy link
benlieb commented Oct 13, 2021

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
Copy link
Author
benlieb commented Mar 30, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0