2017-08-26 182 views
0

你好,我有一個軌道ap運行設計 ...有一個客戶模型。我有一個after_create在客戶上開始@customer = Customer.last我正在尋找澄清.last如果多於一個用戶在一個時間創建一個客戶將.last是準確的或有沒有機會的價值可能是其他用戶對象?Rails.last澄清

例如,我需要指定某種@customer = Customer.last.where(user_id = current_user.id)嗎?

謝謝

回答

1

after_create是類的一個實例方法,因此具有一定的參考對象爲self

所以,你可以做...

@customer = self