Advertisement
rodrigofbm

comments_controller

Aug 27th, 2017
1,336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.32 KB | None | 0 0
  1. class CommentsController < ApplicationController
  2.  
  3.  
  4.     def create
  5.         @post = Post.find(params[:post_id])
  6.         @post.comments.create(post_params)
  7.  
  8.         redirect_to post_path(@post)
  9.     end
  10.  
  11.     private
  12.         def post_params
  13.             params.require(:comment).permit(:name, :body)
  14.         end
  15.  
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement