We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello! It seems I found a bug, @headers variable is nil at csv-safe.rb:56:in `sanitize_row'. Looks like the fix is to read headers as a method.
@headers
headers = %i[a b c] [ [0] :a, [1] :b, [2] :c ] payload = { b: :b, a: :a, c: :c } { :b => :b, :a => :a, :c => :c } CSVSafe.generate(headers: true) { |csv| csv << headers; csv << payload } NoMethodError: undefined method `map' for nil:NilClass from /Users/.../.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/csv-safe-3.1.1/lib/csv-safe.rb:56:in `sanitize_row'
After I changed @headers to headers (then headers.map { |header| sanitize_field(row[header]) }) it works:
headers
then headers.map { |header| sanitize_field(row[header]) }
headers = %i[a b c] [ [0] :a, [1] :b, [2] :c ] payload = { b: :b, a: :a, c: :c } { :b => :b, :a => :a, :c => :c } CSVSafe.generate(headers: true) { |csv| csv << headers; csv << payload } "a,b,c\na,b,c\n"
The text was updated successfully, but these errors were encountered:
if anyone wants to put up a PR to fix this with some tests i will merge it
Sorry, something went wrong.
No branches or pull requests
Hello!
It seems I found a bug,
@headers
variable is nil at csv-safe.rb:56:in `sanitize_row'. Looks like the fix is to read headers as a method.After I changed
@headers
toheaders
(then headers.map { |header| sanitize_field(row[header]) }
) it works:The text was updated successfully, but these errors were encountered: