私の協会
class Website < ApplicationRecord
has_many :settings
has_one :shop
end
設定とショップ テーブルの値は次のとおりです。
2.6.1 :003 > Setting.all.pluck(:records)
=> [2, 2, 4, 0, 0, 0]
2.6.1 :003 > Shop.all.pluck(:records)
=> [4, 1, 1]
結合の使用
Website.joins(:settings, :shop).where("websites.id = ?", 2).pluck("settings.records", "shops.records")
繰り返し値を取得しています
[[2, 4], [2, 1], [2, 1], [2, 4], [2, 1], [2, 1], [4, 4], [4, 1], [4, 1], [0, 4], [0, 1], [0, 1], [0, 4], [0, 1], [0, 1], [0, 4], [0, 1], [0, 1]]
私が欲しい結果
[[2, 4], [2, 1], [4, 1], [0, 0], [0, 0], [0, 0]]
どうすれば問題を解決できますか?
前もって感謝します :)