From 0447b076c690b5ec7453a4623d3e963bea405263 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Mon, 27 Apr 2015 17:59:28 +0200 Subject: [PATCH] set user_type correct for comments --- app/controllers/comments_controller.rb | 2 +- app/controllers/submissions_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 6d670497..b187881d 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -64,7 +64,7 @@ class CommentsController < ApplicationController # POST /comments # POST /comments.json def create - @comment = Comment.new(comment_params.merge(user_type: 'InternalUser')) + @comment = Comment.new(comment_params.merge(user_type: current_user.class.name)) respond_to do |format| if @comment.save diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 21bb26d4..84cec026 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -28,7 +28,7 @@ class SubmissionsController < ApplicationController # copy each annotation and set the target_file.id unless(params[:annotations_arr].nil?) params[:annotations_arr].each do | annotation | - comment = Comment.new(:user_id => annotation[1][:user_id], :file_id => annotation[1][:file_id], :user_type => current_user.user_type, :row => annotation[1][:row], :column => annotation[1][:column], :text => annotation[1][:text]) + comment = Comment.new(:user_id => annotation[1][:user_id], :file_id => annotation[1][:file_id], :user_type => current_user.class.name, :row => annotation[1][:row], :column => annotation[1][:column], :text => annotation[1][:text]) source_file = CodeOcean::File.find(annotation[1][:file_id]) #comment = Comment.new(annotation[1].permit(:user_id, :file_id, :user_type, :row, :column, :text, :created_at, :updated_at))