我有一个收藏:

<Vote id: nil, author_uid: 9326214>,
<Vote id: nil, author_uid: 5643421>,
<Vote id: nil, author_uid: 9753813>

如何获得author_uid值的数组?

谢谢!

最佳答案

Vote.all.pluck(:author_uid)

Ruby on Rails Guide - pluck

关于ruby-on-rails - ActiveRecord::Associations::Collection到Array,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19789077/

10-12 19:03