我有疑问:
Product.all.where(x: @id)
使用
x = ["9", "8", "7","5"] # Array exam
# And
@id = 5
如何检查5
中是否有array
?
答案 0 :(得分:0)
x = [9,8,7,5] #Array测试
@id = 5
if x.include?(@id)
Product.find(@id)
end
或
Product.find(@id) if x.include?(@id)