class HpsClass include Mongoid::Document include Mongoid::Timestamps include OrbitTag::Taggable include OrbitCategory::Categorizable include Slug mount_uploader :course_pic, ImageUploader field :title, as: :slug_title, localize: true has_many :hps_lectures, :autosave => true, :dependent => :destroy def get_runtime hours = 0 mins = 0 self.hps_lectures.pluck(:runtime_hours, :runtime_mins).each do |lec| hours = hours + lec.first mins = mins + lec.last end ht = mins / 60 mt = mins - (ht * 60) hours = ht + hours return hours.to_s + " " + I18n.t("hps_learning.hours") + " " + mt.to_s + " " + I18n.t("hps_learning.minutes") end end