Skip to content

Instantly share code, notes, and snippets.

Created March 14, 2010 08:35
Show Gist options
  • Save anonymous/331860 to your computer and use it in GitHub Desktop.
Save anonymous/331860 to your computer and use it in GitHub Desktop.
class CommentsController < ApplicationController
def index @account = Account.find(params[:account_id]) @comments = @account.comments
end
def show @account = Account.find(params[:account_id]) @comment = @account.comments.find(params[:id])
end
def new @account = Account.find(params[:account_id]) @comment = @account.comments.build
end
def create @account = Account.find(params[:account_id]) @comment = @account.comments.build(params[:comment])
if @comment.save redirect_to post_comment_url(@account, @comment)
else render :action => "new"
end
end
def edit @account = Account.find(params[:account_id]) @comment = @account.comments.find(params[:id])
end
def update @account = Account.find(params[:account_id]) @comment = Comment.find(params[:id])
if @comment.update_attributes(params[:comment]) redirect_to post_comment_url(@account, @comment)
else render :action => "edit"
end
end
def destroy @account = Account.find(params[:post_id]) @comment = Comment.find(params[:id]) @comment.destroy respond_to do |format| format.html { redirect_to post_comments_path(@post) } format.xml { head :ok }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment