LoginSignup
1
0

More than 5 years have passed since last update.

undefined method `+@' for ["2000", "2160", "160", "0"]:Array Did you mean? +

Last updated at Posted at 2018-07-13

型変換しても計算式として扱われているのか、文字列連結がうまくいかない。。

スクリーンショット 2018-07-13 14.01.44.png

配列を並列に持ってきてコーディングしたらエラーが消えました。

    csv_data = CSV.generate(encoding: "UTF-8", headers: true) do |csv|
      csv << column_names
      histories.each.with_index do |history, i|
        部品(略)
        history.order.order_details.each.with_index do |detail, j|
          if history.order.order_code != detail.order.order_code
            同じ注文コードだったら余計なデータを表示しない
          else
            if j != 0
              # csvに空のフィールドを追加したい
              blank_data = []
              8.times do
                blank_data << ""
              end
              csv << blank_data +
              データの配列(略)
            else

              csv << history_row + shipment_row + 
               データの配列(略) +
              ["#{detail.quantity*detail.product_detail.unit_quantity}#{detail.product_detail.unit.name}"]+ history_price_row

              # history_price_rowはStringで出来たArray

            end
          end
        end
      end
    end

2018.07.14(追記)

コメント欄に

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0