Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 有很多:通过vs直截了当属于_Ruby On Rails - Fatal编程技术网

Ruby on rails 有很多:通过vs直截了当属于

Ruby on rails 有很多:通过vs直截了当属于,ruby-on-rails,Ruby On Rails,我一直在为我的应用程序选择正确的模型体系结构。用户可以创建作业(JobRequest),这些作业按计划运行,因此每个JobRequest都有许多次运行(JobRequestRun)。每次运行后,都会生成一个输出文件(OutputDataFile),并附加到JobRequestRun(每次运行仅一个文件)。我应该能够通过调用JobRequest.output_data_files或JobRequestRun.output_data_file来访问这些报告文件。我无法确定我需要的计划: JobReq

我一直在为我的应用程序选择正确的模型体系结构。用户可以创建作业(
JobRequest
),这些作业按计划运行,因此每个
JobRequest
都有许多次运行(
JobRequestRun
)。每次运行后,都会生成一个输出文件(
OutputDataFile
),并附加到
JobRequestRun
(每次运行仅一个文件)。我应该能够通过调用
JobRequest.output_data_files
JobRequestRun.output_data_file
来访问这些报告文件。我无法确定我需要的计划:

JobRequest
  has_many output_data_files, through: job_request_runs

JobRequestRun
  belongs_to output_data_files
  belongs_to job_request

OutputDataFile
  has_many job_requests, through: job_request_runs

# OR

JobRequest
  has_many output_data_files
  has_many job_request_runs

JobRequestRun
  has_one output_data_file
  belongs_to job_request

OutputDataFile
  belongs_to job_request
  belongs_to job_request_run

以下哪一项对你有意义

通过您对问题域的文字描述,我得出以下结论:

class JobRequest < ActiveRecord::Base
  has_many :job_request_runs
  has_many :output_data_files, through: :job_request_runs
end

class JobRequestRun < ActiveRecord::Base
  belongs_to :job_request
  has_one :output_data_file
end

class OutputDataFile < ActiveRecord::Base
  belongs_to :job_request_run
  has_one :job_request, through: :job_request_run
end
类作业请求
通过您对问题域的文本描述,我得出以下结论:

class JobRequest < ActiveRecord::Base
  has_many :job_request_runs
  has_many :output_data_files, through: :job_request_runs
end

class JobRequestRun < ActiveRecord::Base
  belongs_to :job_request
  has_one :output_data_file
end

class OutputDataFile < ActiveRecord::Base
  belongs_to :job_request_run
  has_one :job_request, through: :job_request_run
end
类作业请求
有很多,通过:
不适用于您的体系结构,因为
作业请求
作业请求
运行之间没有多对多关系,
作业请求
运行不能是联接表。
有很多,通过:
不适用于您的体系结构,因为
job\u request
job\u request\u run
之间没有多对多关系,
job\u request\u run
不能是联接表。