Created
August 21, 2008 18:26
-
-
Save batasrki/6607 to your computer and use it in GitHub Desktop.
This file contains 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 | |
skip_before_filter :check_login | |
def create | |
@comment = @post.comments.new | |
@comment.body = params[:comment][:body] | |
@comment.user_directory_id = @me.user_directory_id | |
respond_to do |format| | |
if @comment.save | |
flash[:notice] = "Thank you for your comment" | |
format.html { redirect_to user_post_url(@post.user_directory_id, @post) } | |
format.xml { render :xml => @comment, :status => :created, :location => [@post.user_directory_id, @post] } | |
else | |
flash[:error] = "Comment not posted" | |
format.html { redirect_to user_post_path(@post.user_directory_id, @post) } | |
format.xml { render :xml => @comment.errors, :status => :unprocessable_entity } | |
end | |
end | |
end | |
def destroy | |
@comment = Comment.find(params[:id]) | |
@comment.destroy | |
respond_to do |format| | |
format.html { redirect_to user_post_url(@post.user_directory_id, @post)} | |
end | |
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