aboutsummaryrefslogtreecommitdiffstats
path: root/guides/code/getting_started/app/controllers/comments_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'guides/code/getting_started/app/controllers/comments_controller.rb')
-rw-r--r--guides/code/getting_started/app/controllers/comments_controller.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/guides/code/getting_started/app/controllers/comments_controller.rb b/guides/code/getting_started/app/controllers/comments_controller.rb
new file mode 100644
index 0000000000..7447fd078b
--- /dev/null
+++ b/guides/code/getting_started/app/controllers/comments_controller.rb
@@ -0,0 +1,16 @@
+class CommentsController < ApplicationController
+ http_basic_authenticate_with :name => "dhh", :password => "secret", :only => :destroy
+ def create
+ @post = Post.find(params[:post_id])
+ @comment = @post.comments.create(params[:comment])
+ redirect_to post_path(@post)
+ end
+
+ def destroy
+ @post = Post.find(params[:post_id])
+ @comment = @post.comments.find(params[:id])
+ @comment.destroy
+ redirect_to post_path(@post)
+ end
+
+end