Home>

I got an error when trying to display the details page of what I posted.
In rails routes, it was prototype_path, so it should be correct.

ActionController :: UrlGenerationError in Prototypes # index
Corresponding source code
show.html.erb<main>        <p>    <% = "Prototype title"%>  </p>  <% = link_to "by prototype contributor", root_path, class:: prototype__user%>  <% # Display the following if the poster of the prototype and the logged-in user are the same%>    <% if user_signed_in?&&current_user.id == prototype.user_id%>              <% = link_to "edit", edit_prototype_path, class:: prototype__btn%>      <% = link_to "Delete", root_path, method:: delete, class:: prototype__btn%>    <% end%>          <% # // Show the above if the prototype poster and the logged-in user are the same%>          <% = image_tag.prototype.image, class :: card__img%>                          <p>Catch copy</p>      <p>        <% = "Catch copy of prototype"%>      </p>                      <p>Concept</p>      <p>        <% = "Prototype concept"%>      </p>                  <% # Display the following comment posting form for logged-in users%>       <% = form_with local: true do | f |%>                       <% = f.label: concept, "comment"%><br />           <% = f.text_field: concept%>                                   <% = f.submit "submit", class :: form__btn%>                   <% end%>    <% # // Show the above to logged-in users%>    <ul>      <% # Describe the process of listing the comments associated with the post%>        <li>           <% = "Comment text"%>           <% = link_to "(user name)", root_path, class:: comment_user%>        </li>      <% # // Describe the process to list the comments associated with the post%>    </ul>        </main>
prototypes_controller.rb
class PrototypesController
What I tried

I tried to display the details of the posted content, but I got an ActionController :: UrlGenerationError.
In the rails routes command, the detail page is prototype_path, but I still get an error.

Supplementary information (FW/tool version, etc.)

Please provide more detailed information here.

  • Answer # 1

    _prototype.html.rb
    prototype_path
    ↓
    prototype_path (prototype.id)


    When I changed it to, the details page was displayed.

  • Answer # 2

    Probably because I haven't seen the actual routing,

    prototype_path (params [: id])
    Or
    edit_prototype_path (params [: id])


    I think it will be.
    I think that the target id of show or edit is included in params.

    How is it?