app/controllers/commontator/comments_controller.rb in commontator-1.0.4 vs app/controllers/commontator/comments_controller.rb in commontator-1.0.5
- old
+ new
@@ -25,21 +25,21 @@
@comment.thread = @thread
@comment.creator = @user
raise SecurityTransgression unless @comment.can_be_created_by?(@user)
- if @comment.save
- @thread.subscribe(@user) if @thread.config.auto_subscribe_on_comment
- @thread.add_unread_except_for(@user)
- SubscriptionsMailer.comment_created_email(@comment, @commontable_url)
- else
- @errors = @comment.errors
- end
-
respond_to do |format|
- format.html { redirect_to @thread }
- format.js
+ if @comment.save
+ @thread.subscribe(@user) if @thread.config.auto_subscribe_on_comment
+ @thread.add_unread_except_for(@user)
+ SubscriptionsMailer.comment_created_email(@comment, @commontable_url)
+ format.html { redirect_to @thread }
+ format.js
+ else
+ format.html { redirect_to @thread }
+ format.js { render :new }
+ end
end
end
# GET /comments/1/edit
def edit
@@ -53,14 +53,17 @@
# PUT /comments/1
def update
raise SecurityTransgression unless @comment.can_be_edited_by?(@user)
- @comment.update_attributes(params[:comment])
-
respond_to do |format|
- format.html { redirect_to @thread }
- format.js
+ if @comment.update_attributes(params[:comment])
+ format.html { redirect_to @thread }
+ format.js
+ else
+ format.html { redirect_to @thread }
+ format.js { render :edit }
+ end
end
end
# PUT /comments/1/delete
def delete