From e5a4a1d48d73807a6972deb713450bd2b9de64a3 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Wed, 24 Nov 2021 09:20:25 +0100 Subject: [PATCH] Fix access to CommunitySolution --- app/controllers/community_solutions_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/community_solutions_controller.rb b/app/controllers/community_solutions_controller.rb index 414283c8..ee432fd4 100644 --- a/app/controllers/community_solutions_controller.rb +++ b/app/controllers/community_solutions_controller.rb @@ -29,7 +29,8 @@ class CommunitySolutionsController < ApplicationController if last_contribution.blank? last_contribution = @community_solution.exercise new_readme_file = {content: '', file_type: FileType.find_by(file_extension: '.txt'), hidden: false, read_only: false, name: 'ReadMe', role: 'regular_file', context: @community_solution} - @files << CodeOcean::File.create!(new_readme_file) + # If the first user did not save, the ReadMe file already exists + @files << CodeOcean::File.find_or_create_by!(new_readme_file) end all_visible_files = last_contribution.files.select(&:visible) # Add the ReadMe file first