我在Rails中STI設置(名稱已更改爲保護無辜者)Rails的單表繼承與舊數據
class Mercedes < Car
class BMW < Car
現在,在某個階段,我需要從代碼中刪除對Mercedes
的引用,但由於歷史原因想要保留數據。
當我嘗試從cars
表加載所有的記錄,我得到這個錯誤:
ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed
to locate the subclass: 'Mercedes'. This error is raised because the column 'type'
is reserved for storing the class in case of inheritance. Please rename this
column if you didn't intend it to be used for storing the inheritance class
or overwrite Car.inheritance_column to use another column for that information.
有沒有辦法忽略cars
表,其type
是Mercedes
記錄?
你試圖執行的查詢是什麼 – Bijendra
@GhostRider我試圖在它爆炸時執行BMW.all。所以剩下的數據會使整個表無用。 –