1
我有一個Authorisation
模型,其中有重複的內容。我想刪除所有除基於在Authorisation
一個:provider
列最新,留下我與最近"linkedin"
授權,最近"facebook"
等,等Rails:根據列銷燬除最新版本以外的所有內容
如何將我寫的方法?事情是這樣的邏輯,但它給這個錯誤(TypeError: can't convert Authorisation to Array (Authorisation#to_ary gives NilClass)
):
old = Authorisation.where(provider: 'facebook') - Authorisation.where(provider: 'facebook').last