如何在夹具中指定多态关联
我有这个固定装置:
resource:
name: my resource
owner: user_1 (User)
资源定义如下:
class Resource < ActiveRecord::Base
belongs_to :owner, :polymorphic => true
用户定义如下:
class User < ActiveRecord::Base
has_many :resources, :as => :owner
当我运行测试时,出现错误,表明表中未定义列“所有者”。我做错了什么?
I have this fixture:
resource:
name: my resource
owner: user_1 (User)
Resource is defined like this:
class Resource < ActiveRecord::Base
belongs_to :owner, :polymorphic => true
User is defined like this:
class User < ActiveRecord::Base
has_many :resources, :as => :owner
When I run the test I get an error that the column 'owner' is not defined in the table. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
灯具应具有owner_id 和owner_type。例如:owner_id 为 1,owner_type 为“User”
The fixture should have owner_id and owner_type. For example: owner_id as 1 and owner_type as "User"