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>
Answer # 1
It was solved by changing resources to resources in root.rb!
- ruby on rails - about the error when trying to implement jquery with rails ($is not defined;please fix or add/* global * /)
- ruby on rails 6 - about rails error "wrong number of arguments (given 1, expected 0)"
- ruby - an error occurs when building a rails 6 environment with docker
- ruby on rails 5 - error about rails where method
- ruby on rails - i want to put what i posted on the show page, but it's a blank page it's not an error
- ruby on rails - [rails] about the problem that screen transition is not possible (error does not occur)
- ruby on rails - i want to download a file with rails, s3 and carrierwave, but i get an error
- ruby on rails - rails routing error
- ruby on rails - about switching screen display on multiple models
- ruby on rails 5 - i want to get an error message when i enter the user id in full-width in url
- ruby on rails - i get a template is missing error in render
- ruby - about the delete function in rails
- ruby on rails 6 - [error] nomethoderror in followscontroller # destroy undefined method `destroy'for nil: nilclass
- ruby on rails - uncaught reference error: $is not defined cannot be resolved
- ruby on rails - about the matter that does not transition to the detail page
- ruby on rails 6 - [error] nomethoderror in communitiescontroller # create undefined method `published?'for # <community: 0x0
- ruby on rails - about request spec of rspec about test code at login
- ruby on rails - about the description in applicationjs
- ruby - about routing using rails collection
- ruby - passing variables using render partial
- i get a bundler 213 error when creating an app in ruby 27
- ruby - i want to use the search method for active hash data
- ruby - destroy action does not respond
- ruby - how do you see the rails controller relative path? (carrierwave directory deleted)
- ruby - when deploying on capistrano, i get the error "access denied for user'ec2-user' @'localhost' (using password: no)&qu
- how to reflect the layout downloaded from the external site in ruby on rails?
- ruby - how nice! function routes do not pass well (relation) [rails]
- [ruby/rails] when you want to replace in a specific character string