class CompetitionModule < ApplicationRecord default_scope { order('position ASC') } belongs_to :competition has_one :competition_module_md_content, dependent: :destroy def module_url case module_type when "home" "/competitions/#{competition.identifier}.json" when "inform" "/competitions/#{competition.identifier}/informs.json?status=1" when "manual" "/competitions/#{competition.identifier}/informs.json?status=2" when "chart" "/competitions/#{competition.identifier}/charts.json" when "enroll" "/competitions/#{competition.identifier}/competition_teams.json" else url || "/competitions/#{competition.identifier}/md_content.json?md_content_id=#{competition_module_md_content&.id}" end end end