Ruport - undefined method `each 'for" ": String

sorry for my English.

I follow this tattoo: http://ruportbook.com/printable_documents.html , the first example, but I get the undefined` each 'for "" method: A line all the time, I created a new file with this code:

class MultiTableController < Ruport::Controller    
  stage :multi_table_report    
  class PDF < Ruport::Formatter::PDF    
    renders :pdf, :for => MultiTableController    
    build :multi_table_report do
      data.each { |table| pad(10) { draw_table(table) } }
      render_pdf
    end    
  end    
end

Then, in an existing controller named worker_controller.rb, I put the following action:

  def index_report
    t1 = Table(%w[a b c]) << [1,2,3] << [4,5,6]
    t2 = Table(%w[a b c]) << [7,8,9] << [10,11,12]
    pdf = MultiTableController.render_pdf(:data => [t1,t2])
  end

I added this route to route.rb, of course.

then I get this error in my browser:

undefined method `each' for "1":String

But the error occurs not only in this example, I tried many other examples, and I get the same error.

Some help? In advance! Regards.

+1
source share
2

each String 1.8 Ruby 1.9.

Unicode, , , ruby ​​1.9.

String #each? ? Ruby , String#each_byte String#each_char.

Ruby 1.8 , .


Edit:

:

class String
  alias :each :each_char
end

'aaaa'.each{|x| p x }

, , Ruby 1.9, . , , , .

+9

String.each 1.8.7 , . 1.9 String.split("\n").each String.each. , split , String.each , "/n", String.split("\n").each "\n" .

-1

All Articles