bullet-train-pro / bullet_train-action_models

Other
4 stars 1 forks source link

In PerformsExport, pass fields through I18n before prepending them to the CSV #44

Open petekeen-cf opened 1 year ago

petekeen-cf commented 1 year ago

It would be handy to allow overriding field names as written into the CSV header. For example:

class SomeExportAction < ApplicationRecord
  include Actions::PerformsExport
  AVAILABLE_FIELDS = {
    some_method: true
    another_method: true
  }
end
en:
  some_export_actions
    fields:
      some_method:
        heading: "Some Method"
      another_method:
        heading: "Another Method"

would export

"Some Method","AnotherMethod"
1,"abc"

We could either use the existing heading key or we could use a new csv_heading key if we want it to be different.