Prawn表没有在Rails 4.0和Ruby 2.0中创建

时间:2014-04-28 15:26:09

标签: ruby-on-rails ruby prawn

我有以下表格代码:

  

member_id_and_first_name_and_nps_score_and_comments = [[" 14169021-00",   " Chris",9,"位于佛罗里达州坦帕市的YMCA非常棒。我想要   看到对其他运动的支持程度也提供给   壁球。"],[" 1660592-00"," Nayrone",9,"有这么多   活动产品,有许多便利的地点   整个地区。"],[" 16183029-00"," Mary",9,"我喜欢这里的工作人员   但淋浴很严重,# " 16257833-00"," Phyllis",10," A   舒适的环境,一个可以满足人们和大多数人的地方   重要的是,工作人员随时可用。"],[" 1629846-00"," Joan",   10,"成本,距离,家庭友好"],[" 16204559-00"," Lisa-Marie",   5,"设施相当拥挤,这使得锻炼   设备或参加课程狭窄和困难。 &#34],   [" 16258576-00"," Michael",7," yhe成本方式很多\ r \ n"],   [" 16161644-00"," April",10,""],[" 1663157-00"," Mariela& #34;,10,"太棒了   客户服务,清洁设施和专业人员"],   [" 16114120-00","艾莉森",10," Y提供了很棒的节目,是   积极参与当地社区。 "],[" 16177159-00"," Sheri",10," Y   是一个适合一切的地方。这是一个健身,团契的地方,   社会化,社区,青年向上发展,就业   OPPS ..."]]

table([
        ["Member ID", "First Name", "NPS Score", "Comments"],
        [member_id_and_first_name_and_nps_score_and_comments]
          .transpose.reject{ |x| x[2].nil? }
      ], 
      :position => :center, :column_widths => {0 => 50, 1 => 60, 2 => 45, 3 => 285}) do
        row(0).style :background_color => 'C0C0C0'
      end

该表仅使用标题行(Member ID, First Name, etc.)生成。实际的member_id_and_first_name_and_nps_score_and_comments数组未在列中填充。

为什么会这样想?

1 个答案:

答案 0 :(得分:1)

尝试:

table([
    ["Member ID", "First Name", "NPS Score", "Comments"],
    *member_id_and_first_name_and_nps_score_and_comments.reject{ |x| x[2].nil? }
  ], 
  :position => :center, :column_widths => {0 => 50, 1 => 60, 2 => 45, 3 => 285}) do
    row(0).style :background_color => 'C0C0C0'
  end