2
AR聲明:在下面的MySQL查詢排除ID列從ActiveRecord的結果
Phone.select(:number).distinct.where(in_black_list: true)
結果:
SELECT DISTINCT number FROM phones WHERE phones.in_black_list = 1
結果中包含空的標識:
#<ActiveRecord::Relation [
#<Phone id: nil, number: "1234567">,
#<Phone id: nil, number: "78567459">,
#<Phone id: nil, number: "78567457">,
#<Phone id: nil, number: "998567946794567">,
]>
如何消除這些ID ?