我正在使用Rails 5,我想删除一组对象。在之前的一篇文章中,我读到“destroy_all”是真相和光明。我有对象的两个数组,我减去获得的第三阵列在Rails中,如何删除数组中的所有对象?
unused_currencies = all_currencies - currencies_from_feed
unused_currencies.destroy_all
但使用destroy_all
当我得到这个错误:
NoMethodError: undefined method `destroy_all' for #<Array:0x007feea8878770>
什么定义'currency_from_feed'假设'all_currencies'实际上是'Currency.all',可能有一个干净的范围可以写成处理“unused_currencies”的集合,然后它很简单'Currency.unused_currencies.destroy_all'但没有额外的信息,它将很难帮助 – engineersmnky