2016-09-14 45 views

回答

1

您可以使用uniqpluck做到这一点:

puts Person.uniq.pluck(:birth_date).count == 1 

您还可以使用select方法

puts Person.select('DISTINCT birth_date').count == 1 
+0

我不希望找到一个独特的纪录,我想看看数组@persons中的每个Person具有相同的Person.birth_date。我不想要一个独特的birth_date – NothingToSeeHere

+0

我知道,我的解决方案做到了,lol –

+0

好的。现在我看到了一些睡眠。哈。 – NothingToSeeHere

相关问题