routes.rb
namespace :scheduling do
resources :scheduling_details, only: [:create, :destroy, :update, :index]
do
rake routes
scheduling_scheduling_detail
PATCH /scheduling/scheduling_details/:id(.:format)
scheduling/scheduling_details#update
PUT /scheduling/scheduling_details/:id(.:format)
scheduling/scheduling_details#update
view
<%= link_to "Yes", scheduling_scheduling_detail_path(@scheduling_detail) %>
Error. No route matches [GET] "/scheduling/scheduling_details/6256"
Notice the plural there. I'm not sure why it's trying to access the plural url when I didn't use the plural path shortcut.
So I try to use the manual url instead of the path shortcut
<%= link_to "Yes", "/scheduling/scheduling_detail/#{@scheduling_detail}" %>
Error: No route matches [GET] "/scheduling/scheduling_detail"
Maybe try with the id?
<%= link_to "Yes", "/scheduling/scheduling_detail/#{@scheduling_detail.id}" %>
Error: No route matches [GET] "/scheduling/scheduling_detail/6256"
CodePudding user response:
Try adding :show
to your array, like so:
namespace :scheduling do
resources :scheduling_details, only: [:create, :destroy, :update, :index, :show]
do
And make sure you have a show method in your controller and a view.
CodePudding user response:
As per your routes printout: Your paths are plural. The issue is that you don’t have a GET method, which corresponds to the show view.
You’ll want to change your link_to method to PUT or PATCH.
Something like this in your view should work:
<%= link_to "Yes", scheduling_scheduling_detail_path(@scheduling_detail), method: :put %>
https://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to
CodePudding user response:
You are specifying the wrong path using scheduling_scheduling_detail
you are specifying the #GET
Request you need to use the update_
prefix to specify PUT/PATCH
. The following would do the trick.
<%= link_to "Yes", update_scheduling_scheduling_detail_path(@scheduling_detail) %>