aboutsummaryrefslogtreecommitdiffstats
path: root/guides/code/getting_started/app/controllers/comments_controller.rb
blob: cf3d1be42e36b8bdae62bb276763c6e619743167 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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