Rails 中的“belongs_to_many”用户戳
我尝试更新我的模型,以便它将有一个created_by 和updated_by 字段。看了这里的一些问题和答案,我似乎没有和他们一样的问题。
我的 TestCase 模型应该有一个created_by 和updated_by 外键,但它都应该是一个User 类。这可能吗?
例如:
belongs_to :user, :foreign_key => 'created_by'
belongs_to :user, :foreign_key => 'updated_by'
请记住,created by 和updated_by 可以不同(意味着另一个用户可以编辑测试用例)
Im tryign to update a model of mine so that it will have a created_by and updated_by field. Looking into some questions and answers here, it seems I don't have the same problem as them.
My TestCase model should have a created_by and updated_by foreign key, but it should both be a User class. Is that possible?
something like:
belongs_to :user, :foreign_key => 'created_by'
belongs_to :user, :foreign_key => 'updated_by'
Keep in mind that created by and updated_by can be different(meaning another user can edit the testcase)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用:
您应该通过以下方式引用该对象:
Try to use:
You should refer to that objects through: