0
我正在嘗試編寫一個將整數字段的值增加+1的遷移。我已經嘗試了幾種變化並完成了搜索。我正在尋找的東西是這樣的:在rails 3應用程序中進行的遷移將使整數字段的值增加+1
def self.up
User.update_all(:category => [:category + 1])
end
謝謝。
我正在嘗試編寫一個將整數字段的值增加+1的遷移。我已經嘗試了幾種變化並完成了搜索。我正在尋找的東西是這樣的:在rails 3應用程序中進行的遷移將使整數字段的值增加+1
def self.up
User.update_all(:category => [:category + 1])
end
謝謝。
也許這將做到這一點
User.update_all("category = (category + 1)")