Difference Between pluck and collect
Difference Between pluck and collect Pluck Pluck takes less time then collect because when we use collect we have to execute two queries for collecting record Example- When have a user table and we have to collect all id's User.all.collect(&:id) // when we use collect we are running two query internally first user.all and then we collect id's User.pluck(:id) // Here we are running only one query that's why it take less time Pluck also take more than one parameter at a time but collect can not Example- user.pluck(:id, :name) // it will return array of id and name user.collect(&:id , &:name) // it will give an error