gpt4 book ai didi

ruby-on-rails - ruby 数组中的字符串替换

转载 作者:数据小太阳 更新时间:2023-10-29 07:59:15 25 4
gpt4 key购买 nike

我有以下代码,其中我想将某些值更改为 csv 友好,例如,'nil' 到 ''。我需要知道如何进行这些更改。谢谢。

  def daily_door_schedule
@tickets = Ticket.where(active: true).
pluck(
:door_manufacturer,
:job_number,
:door_style,
:door_allocation_date,
:date_doors_received_in_aub,
:door_delivery_due_date,
:notes
)

respond_to do |format|
format.html
format.csv { render text: @tickets.to_csv }
end
end

最佳答案

应该这样做:

@tickets = Ticket.where(active: true).
pluck(
:door_manufacturer,
:job_number,
:door_style,
:door_allocation_date,
:date_doors_received_in_aub,
:door_delivery_due_date,
:notes
).map { |ticket| ticket.map(&:to_s) }

关于ruby-on-rails - ruby 数组中的字符串替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32464405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com