On the details page for the posted photo
I'm trying to implement a comment feature

First, I want to check "Save comment post"
On the details page (show.html.erb)
I posted it in the comment posting form
Just refresh the details page
Not stored in the database

2Error message
Comments are not saved in the table
  No error code is displayed
3 Applicable source code


<main>        <p>    <% = "Prototype title"%>  </p>  <% = link_to "by # {@ prototype.user.name}", root_path, class:: prototype__user%> <% if user_signed_in?&&current_user.id == @ prototype.user_id%>              <% = link_to "edit", edit_prototype_path (@ prototype.id), method:: get, class:: prototype__btn%>      <% = link_to "Delete", prototype_path (@ prototype.id), method:: delete, class:: prototype__btn%>          <% end%>          <% = image_tag @ prototype.image%>                          <p>Catch copy</p>      <p>       <% [email protected]_copy%>      </p>                      <p>Concept</p>      <p>        <% = @ prototype.concept%>      </p>                         <% if user_signed_in?%>      <% = form_with (model: [@comment, @prototype],

local: true)
           do | f |%>← ** This is the comment form part **
                        <% = f.label: text, "comment"%><br /><% = f.text_field: text%>                                   <% = f.submit "submit", class :: form__btn%>                   <% end%>     <% end%>    <ul>      <% # Describe the process of listing the comments associated with the post%>        <li>          <% #<% = "Comment text"%>          <% #<% = link_to "(username)", root_path, class:: comment_user%>        </li>      <% # // Describe the process to list the comments associated with the post%>    </ul>        </main>


class PrototypesController</pre>
<p><br />
<pre><code>class CommentsController</pre>
<p><br />
<pre><code>Rails.application.routes.draw do
  devise_for: users
  root to:'prototypes # index'
  resources: prototypes do
  resources: comments, only :: create

4 What I researched and tried
Check the association
user model
has_many: prototypes
has_many: comments

prototype model
belongs_to: user
has_many: comments, dependent:: destroy

comment model
belongs_to: prototype
belongs_to: user
I was able to confirm the description of
Also once in the create action part
I used binding.pry,
The process did not stop

def create
  @comment = Comment.new (comment_params)
  if @ comment.save
    redirect_to prototype_path (@ comment.prototype)
  else else
    @prototype = @ comment.prototype
    @comments = @ prototype.comments
    render "prototypes/show"

5 Supplementary information such as the version of the tool i am using