[英]how to write a partial into a cache from a back ground process and read the partial from the cache and render it in rails?
[英]How to write back data in rails
我有一個擁有許多Tickets
的Accounts Controller
Tickets
屬於account
和tickets
接受嵌套屬性的accounts
account
是下一個ticket
號的設置ticket_no
所以我在票證模型中創建了一個函數,如下所示
def store_ticket_no
number = self.account.ticket_no
if !self.ticket_no
self.ticket_no = number
number += 1
end
我嘗試將number.save遞增后如何寫回數字,但是沒有保存方法? 謝謝!
修復了
self.account.update_attribute(:ticket_no , number)
這是正確的方法嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.