0
目前我得到一堆從數據庫中的記錄,並在陣列包裝的記錄,但我想成立一個if條件中它如果其他人在使用數組循環做軌道
@reports = SnapshotReport.includes(camera: [:user]).where(report_date: date)
records = []
@reports.each do |report|
next if report.camera.cloud_recording.blank?
records[records.length] = [
report.camera["name"],
report.camera["exid"],
report.camera.user["firstname"],
report.camera.cloud_recording["storage_duration"],
report.camera["is_online"],
report["snapshot_count"],
report.camera["id"],
report.camera.user["id"],
report.camera.user["lastname"],
]
end
現在我是什麼做的是使用next if
跳過這樣的值,其中
next if report.camera.cloud_recording.blank?
是空的,但我想要做這件事陣列製作部分,但這樣的 如果report.camera.cloud_recording
爲null,則它節省了""
空字符串,但如果報告.camera.cloud_recording存在,則獲得的report.camera.cloud_recording["storage_duration"]
真棒.. !!!謝謝 –