在用 ActiveRecord 的时候比如我想取 user 表的姓名的字段,user.all.name 没有这种方法,我又不想自己把它遍历一边。ActiveRecord 有什么好的方法吗?
use find_each or find_in_batches so Rails can help you to iterate all records but in batches, it will improve query performance. see documents here in details.
but pluck is better in your case.