class Public::CommentsController < ApplicationController def new @comment = Comment.new(:parent_id => params[:parent_id],:commentable_id => params[:commentable_id],:commentable_type => params[:commentable_type]) end def create @comment = Comment.new(params.require(:comment).permit(:website, :pseudo, :email, :comment, :commentable_id, :commentable_type, :parent_id)) @comment.enabled = true if @comment.save commentable = @comment.commentable @comment_id = @comment.id @comment = Comment.new @comment.commentable = commentable end end end