Created
December 30, 2008 01:21
-
-
Save skalnik/41472 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommentsController < ApplicationController | |
before_filter :find_post | |
before_filter :authenticate, :only => :destory | |
def new | |
@comment = @post.comments.build | |
end | |
def create | |
@comment = @post.comments.build(params[:comment]) | |
if @comment.save | |
flash[:notice] = 'Comment was successfully created.' | |
else | |
flash[:notice] = 'There was a trouble saving your comment' | |
end | |
redirect_to @post | |
end | |
def destroy | |
@comment = @post.comments.find(params[:id]) | |
@comment.destroy | |
redirect_to @post | |
end | |
protected | |
def find_post | |
@post = Post.find(params[:post_id]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment