2017-08-26 184 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