Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个模型:具有以下属性的公司和雇主:
Company Name Phone Address Employer Name Phone Address
我想生成如下 CSV 表:
这该怎么做?
只是在折叠循环中进行
UPD:正如 Yuriy 所说,应该使用急切加载
companies = Company.includes(:employers).all ... companies.each do |c| csv << c.info c.employers.each do |e| csv << e.info end end