在 rails 中设置固定对象关系的最佳方法是什么
What is the best way to set relations of fixed objects in rails
您好,我的种子文件中有两种对象 (a,b),我想在它们之间设置关系 a Has_many b 和 b belongs_to a。我该怎么做?
我的想法是将它们创建为种子中的函数,并在创建后更新 b a_id 引用作为仍在种子文件中的函数。
问题是还有 Ruby 方法吗?
a = A.create
a.bs.create(b_params)
您好,我的种子文件中有两种对象 (a,b),我想在它们之间设置关系 a Has_many b 和 b belongs_to a。我该怎么做?
我的想法是将它们创建为种子中的函数,并在创建后更新 b a_id 引用作为仍在种子文件中的函数。
问题是还有 Ruby 方法吗?
a = A.create
a.bs.create(b_params)