Rails 5 polymorphic Comment model, I am using devise.
When I create "new" comment, the params permitted => always false; Even I use params.permit(:all)
class Comment < ApplicationRecord
belongs_to :commentable, polymorphic: true
has_many :comments, as: :commentable
default_scope ->{ order('created_at DESC') }
validates_presence_of :title
validates_presence_of :description
end
views/comments/_form.html.erb
<%= form_with(model: comment, local: true) do |form| %>
comments_controller.rb
def comment_params
params.fetch(:client, {})
params.require(:comment).permit(:title, :description)
params.permit(:all)
byebug
end
82: params.fetch(:client, {})
83: params.require(:comment).permit(:title, :description)
84: #params.permit(:title, :description, :client_id)
85: params.permit(:all)
86: byebug
=> 87: end
88:
89: def find_commentable
90: # @commentable = Client.find(params[:client_id])
if params[:client_id]
91: # for now
(byebug) params
comments#createaction to your question? - slehmann36