I've defined custom URL paths in routes.rb, but my _path and _url helpers produce additional, incorrect routes.
routes.rb
get '/:id', to: 'groups#show', constraints: proc {|req| FriendlyId::Slug.where(sluggable_type: 'Group').pluck(:slug).include?(req.params[:id])}, as: :group
get '/:id', to: 'custom_pages#show', constraints: proc {|req| FriendlyId::Slug.where(sluggable_type: 'CustomPage').pluck(:slug).include?(req.params[:id])}, as: :custom_page
get ':group_id/:id', to: 'exams#show', constraints: proc {|req| FriendlyId::Slug.where(sluggable_type: 'Exam').pluck(:slug).include?(req.params[:id])}, as: :exam
Expected routes:
- /custom/
- /test/
- /test/exam/
Actual routes:
- /custom/
- /test/
- /test/exam/ (does load, but not defined
_pathor_url) - /exam/ (defined for
_path&_url)
So all the desired routes do load, but the _path and _url helpers persistently display the wrong path for exam (/exam/) despite not being in routes.rb. :/
What am I doing wrong?