Skip to content

Instantly share code, notes, and snippets.

@baileylo
Created October 19, 2010 08:32
Show Gist options
  • Save baileylo/633839 to your computer and use it in GitHub Desktop.
Save baileylo/633839 to your computer and use it in GitHub Desktop.
Created functions for reply to posts
# GET /conversations/reply
def reply
@conversation = Conversation.find(params[:id])
@comment = @conversation.comments.build
respond_to do |format|
format.html #reply.html.erb
end
end
# POST /conversations/reply
def save_reply
if !current_user
redirect_to(:login, :notice =>"Please login before posting")
return 1;
end
if Conversation.exists?(params[:id])
@conversation = Conversation.find(params[:id])
@comment = @conversation.comments.build(params[:comment])
@comment.user_id = current_user.id
else
redirect_to(boards_path, :notice =>"Please specify a valid board")
end
respond_to do |format|
if current_user && @comment.save
format.html { redirect_to(board_path(@board), :notice => 'Your reply was posted') }
else
format.html { render :action => "new" }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment