apps:
ID (PK)
name
status_id (FK to status table)
status:
ID(PK)
name
class App < ActiveRecord::Base
belongs_to :status
end
class Status < ActiveRecord::Base
has_many :apps
end
我有幾個狀態。
Name PK
Unreviewed (1)
Reviewed (2)
Beta (3)
我想將狀態爲'測試版'的所有應用狀態更改爲狀態'未審覈'。主鍵是存儲在Apps表中的內容。但是我不想只是PK的關鍵,因爲它可能在所有數據庫中都不完全相同。我想關閉更新的狀態名稱。
我似乎無法弄清楚如何在Apps表上發出update_all。
嘗試這樣做,但它不工作 App.update_all(:狀態=> '測試',:狀態=> '測試版')
你可以發表你的模型看起來怎麼樣,有什麼屬性 – Zippie