Route fails to match despite matching route found in rails routes
No route matches {:action=>"update", :controller=>"croppable_images", :name=>"cover_photo", :record_type=>"Stager"}, possible unmatched constraints: [:name] excluded from capture: No host specified, no public_key specified, no project_id specified
ActionController::UrlGenerationError (No route matches {:action=>"update", :controller=>"croppable_images", :name=>"cover_photo", :record_type=>"Stager"}, possible unmatched constraints: [:name]):
app/controllers/croppable_images_controller.rb:19:in `edit'
127.0.0.1 - - [04/Feb/2022:16:28:44 CST] "GET /stager/profile/cover_photo HTTP/1.1" 500 143893
http://localhost:3000/stager/profile -> /stager/profile/cover_photo
The route call
@edit_image_url = stagers_stager_croppable_image_path('cover_photo')
<%=
form_for(
@croppable_image,
url: @edit_image_url,
method: :put
) do |f|
%>
routes.rb section:
namespace :stagers, path: 'stager' do
resource(
:stager,
path: 'profile',
only: %i[edit update],
path_names: {
edit: ''
}
) do
%w[
profile_photo
cover_photo
].each do |croppable_image_name|
resources(
:croppable_image,
controller: '/croppable_images',
path: '',
param: :name,
only: %i[edit update],
path_names: {
edit: ''
},
defaults: {
record_type: 'Stager'
},
constraints: {
name: croppable_image_name
}
)
end
end
end
The route:
| Helper | HTTP Verb | Path | Controller#Action |
|---|---|---|---|
| edit_stagers_stager_croppable_image_path | GET | /stager/profile/:name(.:format) | croppable_images#edit {:record_type=>"Stager", :name=>"profile_photo"} |
| stagers_stager_croppable_image_path | PATCH | /stager/profile/:name(.:format) | croppable_images#update {:record_type=>"Stager", :name=>"profile_photo"} |
| PUT | /stager/profile/:name(.:format) | croppable_images#update {:record_type=>"Stager", :name=>"profile_photo"} | |
| GET | /stager/profile/:name(.:format) | croppable_images#edit {:record_type=>"Stager", :name=>"cover_photo"} | |
| PATCH | /stager/profile/:name(.:format) | croppable_images#update {:record_type=>"Stager", :name=>"cover_photo"} | |
| PUT | /stager/profile/:name(.:format) | croppable_images#update {:record_type=>"Stager", :name=>"cover_photo"} |