|
|
@ -89,7 +89,9 @@ class CompetitionsController < ApplicationController
|
|
|
|
def create_md_content
|
|
|
|
def create_md_content
|
|
|
|
md_content = CompetitionModuleMdContent.find params[:md_content_id]
|
|
|
|
md_content = CompetitionModuleMdContent.find params[:md_content_id]
|
|
|
|
md_content.update_attributes(params[:md_content])
|
|
|
|
md_content.update_attributes(params[:md_content])
|
|
|
|
md_content.save_attachments(params[:attachments])
|
|
|
|
attachment_ids = params[:attachments].values.map{|a| a[:attachment_id]}.compact
|
|
|
|
|
|
|
|
Attachment.where(:id => attachment_ids)
|
|
|
|
|
|
|
|
.update_all(container_id: md_content.id, container_type: 'CompetitionModuleMdContent') if attachment_ids
|
|
|
|
redirect_to md_contents_competition_url(:md_content_id => md_content.id)
|
|
|
|
redirect_to md_contents_competition_url(:md_content_id => md_content.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -103,7 +105,9 @@ class CompetitionsController < ApplicationController
|
|
|
|
def update_md_content
|
|
|
|
def update_md_content
|
|
|
|
md_content = CompetitionModuleMdContent.find params[:md_content_id]
|
|
|
|
md_content = CompetitionModuleMdContent.find params[:md_content_id]
|
|
|
|
md_content.update_attributes(params[:md_content])
|
|
|
|
md_content.update_attributes(params[:md_content])
|
|
|
|
md_content.save_attachments(params[:attachments])
|
|
|
|
attachment_ids = params[:attachments].values.map{|a| a[:attachment_id]}.compact
|
|
|
|
|
|
|
|
Attachment.where(:id => attachment_ids)
|
|
|
|
|
|
|
|
.update_all(container_id: md_content.id, container_type: 'CompetitionModuleMdContent') if attachment_ids
|
|
|
|
redirect_to md_content_competitions_path(:md_content_id => md_content.id)
|
|
|
|
redirect_to md_content_competitions_path(:md_content_id => md_content.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|