Skip to content

Instantly share code, notes, and snippets.

@rizkylab
Last active August 29, 2015 14:12
Show Gist options
  • Save rizkylab/db64306dc82909c00706 to your computer and use it in GitHub Desktop.
Save rizkylab/db64306dc82909c00706 to your computer and use it in GitHub Desktop.
class CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create(params[:comments])
@comment.save
redirect_to post_path(@post)
end
def destroy
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:id])
@comment.destroy
redirect_to post_path(@post)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment