rails icon indicating copy to clipboard operation
rails copied to clipboard

Render URLs without numbers for singular resource routes

Open paulreece opened this issue 2 years ago • 5 comments

This fix allows the polymorphic_method in the HelperMethodBuilder class in polymorphic_routes.rb discern whether or not a singular resource is being passed into it. If it finds a singular resource it will pass in format: nil to the options so that we can have an edited object using the patch method get sent to the proper URL instead of appending a period and number to the end. I believe this is a better implementation than my first try. This works for nested and non nested routes utilizing resource

The current bug behavior in 7.1:

Started PATCH "/author.1" for ::1 at 2023-10-12 15:03:31 -0400

This fix corrects this to:

Started PATCH "/author" for ::1 at 2023-10-12 15:03:31 -0400

Fixes #49604

Checklist

Before submitting the PR make sure the following are checked:

  • [x] This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • [x] Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • [x] Tests are added or updated if you fix a bug or add a feature.
  • [x] CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

paulreece avatar Nov 01 '23 21:11 paulreece

I think this requires a CHANGELOG entry, as this is a behavioural change

p8 avatar Nov 02 '23 09:11 p8

I think this requires a CHANGELOG entry, as this is a behavioural change

Thanks for taking a look Petrik! I just implemented all of your suggestions.

paulreece avatar Nov 02 '23 12:11 paulreece

Reopening, not sure why it closed.

paulreece avatar Nov 04 '23 13:11 paulreece

Reopening, not sure why it closed.

You were pushed 0 commit.

akhilgkrishnan avatar Nov 04 '23 13:11 akhilgkrishnan

You were pushed a 0 commit.

Yeah I was confused because I added the files to push locally. Something got lost in the process somewhere.

paulreece avatar Nov 04 '23 13:11 paulreece