新手问题 如何利用 seed 构建关联数据

luliangshu · July 07, 2014 · Last by luliangshu replied at July 07, 2014 · 1409 hits

我有 product,product_tag 这 2 个表 一对多的关系

Product.create([
    { product_tag_id: [1,2,3] }
])

报错

unknown attribute: product_tag_id

难道我需要在 product 去建这个字段?可是 rails_admin 已经读出来这个字段了 说明关联成功了

product_tag_ids

@Rei 成功了 万分感谢

You need to Sign in before reply, if you don't have an account, please Sign up first.