带有虚拟属性的 after_save 回调 Rails 3
我不知道这是否可能,所以我想我会问。
1. Give a model some virtual attributes
2. Assign values to the model and the virtual attributes
3. Save the model
4. Use a callback after_save to create a different object with the virtual attributes.
这可以在 Rails 3 中完成吗?
I don't know if this is possible so I thought I would ask.
1. Give a model some virtual attributes
2. Assign values to the model and the virtual attributes
3. Save the model
4. Use a callback after_save to create a different object with the virtual attributes.
Can this be done in Rails 3?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只要关联与您无关,请使用:
http://apidock.com/rails/ActiveRecord/基础/克隆
As long as associations are irrelevant for you, use:
http://apidock.com/rails/ActiveRecord/Base/clone