Created
October 19, 2010 08:32
-
-
Save baileylo/633839 to your computer and use it in GitHub Desktop.
Created functions for reply to posts
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
# 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