rodrigofbm

comments_controller

Aug 27th, 2017
722
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data