Home>

I'm implementing a like function when developing a posting app, but I'm stuck with a "Routing Error".
Which part of the code below is causing the error?
Thanks for your cooperation.
(If i have other necessary data for confirmation, we will send it in the comment section.)

↓ Error details

Routing Error
No route matches [DELETE] "/ books/6/favorites"
Rails.root: /home/ec2-user/environment/Bookers2
Application Trace | Framework Trace | Full Trace
Routes
Routes match in priority from top to bottom

<% if @ book.errors.any?%>
    <% = @ book.errors.count%>error prohibited this obj from being saved:
    <% @ book.errors.full_messages.each do | message |%>
      <% = message%>
    <% end%>
  <% end%>
  
    
    <% = render'layouts/list', book: @book, user: current_user%>
    
    
       Books 
    <table>
      <thead>
        <tr>
          <td></td>
          <td>Title</td>
          <td>Opinion</td>
        </tr>
      </header>
      <tbody>
      <% @ books.each do | book |%>
        <tr>
          <td>
            <% = link_to user_path (book.user) do%>
              <% = attachment_image_tag book.user,: profile_image, format:'jpeg', fallback: "no_image.jpg", size: "100x100"%>
            <% end%>
          <td>
            <% = link_to book_path (book) do%>
              <% = book.title%>
            <% end%>
          </td>
          <td><% = book.body%></td>
          <td>
          <% if book.favorited_by? (current_user)%>
Error location →<% = link_to book_favorites_path (book), method :: delete do%>
                ♥<% = book.favorites.count%>
            <% end%>
          <% else%>
            <% = link_to book_favorite_path (book), method:: post do%>
                ♡<% = book.favorites.count%>
            <% end%>
          <% end%>
          </td>
        </tr>
      <% end%>
      </tbody>
    </table>
    
  

<br>
<p>CopyRight Infratop.inc</p>
class FavoritesController
  • Answer # 1

    It was solved by changing resources to resources in root.rb!