0
我試圖通過一組ID來選擇,但只有在shown
列爲真時纔可以。我想: Product.find(@product_ids, conditions: "shown = true")
通過ID找到欄位爲真的軌道
不過是給我的錯誤:Couldn't find all Products with IDs (2, 3) [WHERE (shown = true)] (found 0 results, but was looking for 2)
在這種特殊情況下,這兩種選擇的產品有shown
設置爲false。
從導遊:「Model.find(array_of_primary_key),將會提高一個ActiveRecord :: RecordNotFound例外,除非匹配的記錄,發現所有的提供的主鍵「。這就是爲什麼你收到這個例外。 –