diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index b790977e2..1c8745dae 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -62,6 +62,15 @@ class CommentsController < ApplicationController end end + def undelete + @comment = Comment.find(params[:id]) + check_privilege(@comment) + @comment.undelete! + respond_with(@comment) do |format| + format.js + end + end + def unvote @comment = Comment.find(params[:id]) @comment.unvote! diff --git a/app/models/comment.rb b/app/models/comment.rb index 0521ba47c..1b0b08660 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -9,7 +9,7 @@ class Comment < ActiveRecord::Base before_validation :initialize_updater after_create :update_last_commented_at_on_create after_destroy :update_last_commented_at_on_destroy - attr_accessible :body, :post_id, :do_not_bump_post + attr_accessible :body, :post_id, :do_not_bump_post, :is_deleted module SearchMethods def recent @@ -175,6 +175,10 @@ class Comment < ActiveRecord::Base def delete! update_attributes(:is_deleted => true) end + + def undelete! + update_attributes(:is_deleted => false) + end end Comment.connection.extend(PostgresExtensions) diff --git a/app/views/comments/partials/show/_comment.html.erb b/app/views/comments/partials/show/_comment.html.erb index 0856a738d..e63efed59 100644 --- a/app/views/comments/partials/show/_comment.html.erb +++ b/app/views/comments/partials/show/_comment.html.erb @@ -25,7 +25,11 @@ <% if @post || @posts %>