工厂女孩通过协会实现了很多
我有两个模型书籍和作者,由 books_authors 模型加入。一本书通过 books_authors 模型拥有多个作者,一个作者通过 books_authors 模型拥有多本书。现在我需要为书籍和作者创建工厂。
我创建了一个图书工厂,比如说一本名为“Beginning with FactoryGirl”的书,以及两个为作者创建的工厂,比如名为“Author 1”和“Author 2”的书。现在,我想将两个作者工厂与图书工厂关联起来。我如何在 book.rb 工厂中实现它?
I have two models books and authors joined by books_authors model. A book has many authors through books_authors model and an author has many books through books_authors model. Now I need to create factories for books and authors.
I have created a book factory say a book with name "Beginning with FactoryGirl" and two factories for authors like say with name "Author 1" and "Author 2". Now, I want to associate the two author factories with the book factory. How can I implement that in the book.rb factory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的东西...
Something like this...