Ruby Controller example

Ruby code posted by d4x
created at 25 Mar 10:42

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class CommentsController < ApplicationController

  def create
    @post = Post.find(params[:post_id])
    @comment = @post.comments.create(params[:comment])
    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
383 Bytes in 3 ms with coderay