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

CSV column order bug #2727

Closed
silva96 opened this issue Sep 28, 2016 · 1 comment
Closed

CSV column order bug #2727

silva96 opened this issue Sep 28, 2016 · 1 comment

Comments

@silva96
Copy link

silva96 commented Sep 28, 2016

When mixing up schema fields and custom methods in the export configuration we would like the csv to preserve the order of the columns as they were defined in the configuration.

But this line of code

@methods = [(schema[:only] || []) + (schema[:methods] || [])].flatten.compact

Is taking all schema fields first, then all methods and , so the order is messed up.

The workaround is to define columns as methods.

example:

should be as field like this
field :bank_name

redefined as custom method

field :bank_name_column do
  formatted_value do
    t = bindings[:object]
    t.bank_name
  end
  label 'Bank Name'
end
@mshibuya
Copy link
Member

Merging into #2580.

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

2 participants