Ruby on rails 使用CollectionIn中的数据创建数组

Ruby on rails 使用CollectionIn中的数据创建数组,ruby-on-rails,ruby,collections,Ruby On Rails,Ruby,Collections,我有这个收藏 <ActiveRecord::Associations::CollectionProxy [#<Fallower user_id: 1, author_id: 2, created_at: "2015-09-06 22:59:40", updated_at: "2015-09-06 22:59:40">, #<Fallower user_id: 1, author_id: 3, created_at: "2015-09-06 22:59:40", updat

我有这个收藏

<ActiveRecord::Associations::CollectionProxy [#<Fallower user_id: 1, author_id: 2, created_at: "2015-09-06 22:59:40", updated_at: "2015-09-06 22:59:40">, #<Fallower user_id: 1, author_id: 3, created_at: "2015-09-06 22:59:40", updated_at: "2015-09-06 22:59:40">]>
我需要创建一个仅包含authord_id值的数组/集合

最好的方法是什么?怎样做

@fallowers = Fallower.where(<something>)
@authord_ids = @fallowers.map(&:authord_id)

我建议你使用

我建议你使用

我建议你使用

我建议你使用

试试:

Fallower.all.collect {|f| f.author_id}

另外,你确定你指的是Fallower而不是Follower吗?

试试:

Fallower.all.collect {|f| f.author_id}

另外,你确定你指的是Fallower而不是Follower吗?

试试:

Fallower.all.collect {|f| f.author_id}

另外,你确定你指的是Fallower而不是Follower吗?

试试:

Fallower.all.collect {|f| f.author_id}



而且,你确定你指的是Fallower而不是Follower吗?

我还建议你修正Fallower=>Followerd打字错误。你怎么知道这是一个打字错误?称之为有根据的猜测。我还建议你修正Fallower=>Followerd打字错误。你怎么知道这是一个打字错误?称之为有根据的猜测。我还建议你修正Fallowerd=>Followerd打字错误。你怎么知道知道这是一个拼写错误吗?称之为有根据的猜测。我还建议您修复未处理的=>后续拼写错误。您如何知道这是一个拼写错误?称之为有根据的猜测。我看到Pulk有更快的基准测试,但我忘了LinkPulk使用表中的select列生成sql查询,它比加载所有记录和映射都要快。我看到Pulk有更快的基准测试,但我忘记了LinkPulk使用select column from table生成sql查询,它比加载所有记录和映射更快。我看到Pulk有更快的基准测试,但我忘了LinkPulk使用select column from table生成sql查询,它比加载所有记录和映射都要快。我看到Pulk有更快的基准测试,但我忘记了LinkPulk使用select column from table生成sql查询,它比加载所有记录并在其上映射要快。使用Pulk的解决方案效率更高,因为您获取完整记录的目的不只是为了压缩单个列数组。@max true,发布后考虑一下!使用Pulk的解决方案效率更高,因为获取完整记录并不是为了压缩成一个单列数组。@max true,发布后考虑一下!使用Pulk的解决方案效率更高,因为获取完整记录并不是为了压缩成一个单列数组。@max true,发布后考虑一下!使用Pulk的解决方案效率更高,因为获取完整记录并不是为了压缩成一个单列数组。@max true,发布后考虑一下!