From d5571b38fa9785ba3e928a6f845bc8c3811f8348 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Sat, 1 Aug 2015 01:03:01 +0200 Subject: [PATCH] AutoCommit Sam Aug 1 01:03:01 CEST 2015 --- app/controllers/comments_controller.rb | 3 ++- app/views/comments/create.js.erb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 4ab2988..a5007e6 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -54,10 +54,11 @@ num = {"Beispiel"=> 2, "Survey::Question"=> 7} if @comment format.html { redirect_to @comment.commentable, notice: 'Comment was successfully created.', show_comments: true } format.json { render json: @comment, status: :created, location: @comment } - + format.js else format.html { render action: "new" } format.json { render json: @comment.errors, status: :unprocessable_entity } + format.js {render action:"new"} end end end diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index 1a20c2e..3f6e83f 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -1 +1,2 @@ -$("#<%= @comment.commentable.formid %>").html("") +$("#<%= Comment.formid_for(@comment.parent) %>").html("") +$("#<%= Comment.wrapid_for(@comment.commentable) %>").html("<%= escape_javascript render partial:"comments/comments", object: @comments %>")