我有以下代码,其中我想将某些值更改为csv friendly,例如,' 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
答案 0 :(得分:3)
这应该这样做:
@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) }