Ruby on rails 未使用to_xls显示标题

Ruby on rails 未使用to_xls显示标题,ruby-on-rails,ruby,export-to-excel,Ruby On Rails,Ruby,Export To Excel,我正在使用gem,从activerecords生成xls文件非常棒。但由于某些原因,我无法获得标题显示 这是控制器: format.xls { send_data @tickets.to_xls( :columns => [:created_at, :title, {:category => :title}, {:group => :name}, {:location => :name}, :starts, :target, {:requesto

我正在使用gem,从activerecords生成xls文件非常棒。但由于某些原因,我无法获得标题显示

这是控制器:

  format.xls {
    send_data @tickets.to_xls(
      :columns => [:created_at, :title, {:category => :title}, {:group => :name}, {:location => :name}, :starts, :target, {:requestor => :full_name}, :percent_complete, :recurring, :cost, :spent, :task_level],
      :headers => [:created, :name, :category, :group, :location, :start_date, :target_date, :requestor, :percent_complete, :recurring, :cost, :spent, :task_level]
    )
  }

to_xls插件不显示带有关联模型的标题,因为它无法理解属性名称

您可以尝试为标题而不是属性指定字符串:

format.xls {
    send_data @tickets.to_xls(
      :columns => [:created_at, :title, {:category => :title}, {:group => :name}, {:location => :name}, :starts, :target, {:requestor => :full_name}, :percent_complete, :recurring, :cost, :spent, :task_level],
      :headers => ["created", "name", "category", "group", "location", "start_date", "target_date", "requestor", "percent_complete", "recurring", "cost", "spent", "task_level"]
    )
}

你不会碰巧在任何地方有(:headers=>false)吧?不会。正如你所看到的。我能想到的唯一可能的另一件事是:标题到:列:S的数量不正确。我觉得这很好。是的,这就是我所想的,但我已经计算了4次,看看是否有正确的数量。我实际上联系了宝石的创建者,他说这是一个缺陷。它现在已经修好了,并且按照我问题中的方式工作。谢谢