开发者

How to specify a polymorphic association in a fixture

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 tha开发者_开发问答t the column 'owner' is not defined in the table. What am I doing wrong?


The fixture should have owner_id and owner_type. For example: owner_id as 1 and owner_type as "User"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜