在我的ruby on rails应用程序中,我试图在克隆后保存模型时出现问题。我有以下模型。 class Company < ApplicationRecord
has_many :employees
end
class Employee < ApplicationRecord
belongs_to :company
has_one :user
end
所以我试图使用dup()将标准输出重定向到文件。 int save_fd;
save_fd=dup(1); //saves the current stdout
close(1); //closes stdout
dup2(file.txt, 1);//redirect output to file.txt
//output goes to file.txt
dup2(save_fd