我在产品控制器索引方法中有这段代码:
  def index
    @products = Product.all
    respond_to do |format|
      format.html
      format.pdf do
        pdf = PDF::Writer.new
        @products.each do |product|
          pdf.text product.name 
        end        
        send_data pdf.render, :filename => 'products.pdf', :type => 'application/pdf', :disposition => 'inline'
      end
    end   
  end
在 environment.rb 文件中
require 'pdf/writer'
Mime::Type.register 'application/pdf', :pdf
运行程序时出现错误
“笔”的未定义方法“每个”:字符串