-2
 def generate_report
    tablica = []
    tablica << 1
    Prawn::Document.generate("test.pdf") { tablica.each { |a| text a } }
  end

Why this code doesn't work in Prawn??? Which code is correct??

lucapette
  • 20,564
  • 6
  • 65
  • 59
Michał Makaruk
  • 283
  • 1
  • 2
  • 8

2 Answers2

1

Try this:

require 'prawn'

def generate_report
  tablica = []
  tablica << 10
  Prawn::Document.generate("test.pdf") { tablica.each { |a| text a.to_s } }
end

generate_report

You should pass parameter as 'string' in text method.

Anthony Pegram
  • 123,721
  • 27
  • 225
  • 246
WarHog
  • 8,622
  • 2
  • 29
  • 23
1

Because you're passing a number, not a string.

def generate_report
  tablica = []
  tablica << 1
  Prawn::Document.generate("test.pdf") { tablica.each { |a| text "#{a}" } }
end
Dave Newton
  • 158,873
  • 26
  • 254
  • 302