Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CommentsController < ApplicationController
- def index
- @post = Post.find(params[:post_id]
- @comments = @post.comments
- end
- def show
- @post = Post.find(params[:post_id]
- @comment = @post.comments.find(params[:id])
- end
- def new
- @post = Post.find(params[:post_id]
- @comment = @post.comments.build
- end
- def edit
- @post = Post.find(params[:post_id]
- @comment = Comment.find(params[:id])
- if @comment.update_attributes(paramas[:comment])
- redirect_to post_comment_url(@post,@comment)
- else
- render :action => "edit"
- end
- end
- def destroy
- @post = Post.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
Add Comment
Please, Sign In to add comment