I am trying to use the button_to rails button_to . I wrote the following code:
<%= button_to 'Edit Item', edit_item_path(@item), :class => 'mark-button' %>
and received the following error message
No route matches "/items/1/edit"
But when I refresh the page, it goes to the appropriate action. The url of the page I get is localhost:3000/items/1/edit , which is the correct url. If I switch the button_to command to link_to , the page will load without errors. The meaning of this code is:
<%= link_to 'Edit Item', edit_item_path(@item), :class => 'mark-button' %>
loading normally. Perhaps there is some kind of button_to feature that I donβt know about, but I'm losing.
ruby ruby-on-rails button link-to
Nayish
source share