如果我这样做User.all.pluck(:email)
那就行了.
但如果我这样做
arr = Array.new
arr = User.all
Run Code Online (Sandbox Code Playgroud)
然后
arr.pluck(:email)
Run Code Online (Sandbox Code Playgroud)
这引起了以下错误
undefined method `pluck' for #<Array:0x007f4ff8daf3c8>
Run Code Online (Sandbox Code Playgroud)
这意味着我不能使用数组,所以我们如何从上面的一行记录数组中获取特定的字段值. 我不想循环遍历数组中的每个记录.