我知道有3種主要符號(hào)為whereActiveRecord方法提供參數(shù):純弦數(shù)組雜湊指定and的where方法是直截了當(dāng):# Pure String notationPerson.where("name = 'Neil' AND age = 27")# Array notationPerson.where(["name = ? AND age = ?", 'Neil', 27])# Hash notationPerson.where({name: "Neil", age: 27})指定or相同的where方法讓我很困惑哈希語(yǔ)法??赡軉??# Pure String notationPerson.where("name = 'Neil' OR age = 27")# Array notationPerson.where(["name = ? OR age = ?", 'Neil', 27])# Hash notation DOESN'T WORKPerson.where({name: "Neil" OR age: 27})
ActiveRecord或查詢哈希符號(hào)
慕尼黑的夜晚無(wú)繁華
2019-11-28 10:44:56