你好我有一个rails ap运行设计..。有一个客户模型。我有一个after_create on customer,从@customer = Customer.last开始,我想要澄清.last,如果一个用户一次创建一个客户,.last是准确的还是有可能这个值可以是其他用户的对象?
例如,我是否需要指定某种类型的@customer = Customer.last.where(user_id = current_user.id)?
谢谢
发布于 2017-08-26 22:45:38
after_create是类的实例方法,因此它将对象引用为self。
所以你可以做..。
@customer = selfhttps://stackoverflow.com/questions/45900175
复制相似问题