# This is a Foreign Object Reference Table, keyed to the external data source by #recording_uuid class Recording < ApplicationRecord belongs_to :course belongs_to :lecture, optional: true def recording_url return nil if recording_uuid.nil? "https://uniofbath.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=#{recording_uuid}" end def nice_title if course.title == "General Relativity" regex = /.+L(\d+).*/ lecture_number = self.title.match(regex)[1].to_i return "Lecture #{lecture_number}" end title end def create_lecture!(fixup_time: false) Lecture.create!( title: nice_title, course: course, recording: self ) end end