You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/models/competition_module.rb

19 lines
761 B

class CompetitionModule < ApplicationRecord
default_scope { order('position ASC') }
belongs_to :competition
has_many :competition_module_md_contents, dependent: :destroy
def module_url
result_url = url.present? ? url : case module_type
when "chart"
"/competitions/#{competition.identifier}/charts.json"
when "enroll"
"/competitions/#{competition.identifier}/competition_teams.json"
else
"/competitions/#{competition.identifier}/competition_modules/#{id}.json"
end
end
end