问题:如果连接表的属性大于/小于某个值,则可以在散列条件下进行测试
示例:测试actor年龄是否大于ageVariable:
是否可以在 ARRAY CONDITION 中写而不是:
ageVariable = 36<br> Movie.includes(:actors).where("actors.age > ?", ageVariable)
HASH CONDITION 类似于:
ageVariable = 36
Movie.includes(:actors).where(:actors => { :age => COMPARE_LOGIC })
# Where COMPARE_LOGIC is something like: (:age > ageVariable)
答案 0 :(得分:7)
http://guides.rubyonrails.org/active_record_querying.html#hash-conditions
只有使用哈希条件才能进行相等,范围和子集检查。