class CompetitionModule < ApplicationRecord default_scope { order('position ASC') } belongs_to :competition has_one :competition_module_md_content, dependent: :destroy def module_url case name when "首页", "赛制介绍" "/competitions/#{competition.identifier}" when "通知公告" "/competitions/#{competition.identifier}/informs?status=1" when "参赛手册" "/competitions/#{competition.identifier}/informs?status=2" when "排行榜" "/competitions/#{competition.identifier}/charts" when "报名" "/competitions/#{competition.identifier}/competition_teams" else url || "/competitions/#{competition.identifier}/md_content?md_content_id=#{competition_module_md_content&.id}" end end end