Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cause rails to correctly place optional path parameters
previously, if you specify a url parameter that is part of the path as false it would include that part of the path as parameter at the end of the url instead of in the path for example: `get "(/optional/:optional_id)/things" => "foo#foo", as: :things` `things_path(optional_id: false) # => /things?optional_id=false` this is not the case for empty string, `things_path(optional_id: '') # => "/things" this is due to a quark in how path parameters get removed from the parameters. we where doing `(paramter || recall).nil?` which returns nil if both values are nil however it also return nil if one value is false and the other value is nil. i.e. `(false || nil).nil # => nil` which is confusing. After this change, `true` and `false` will be treated the same when used as optional path parameters. meaning now, ``` get '(this/:my_bool)/that' as: :that that_path(my_bool: true) # => `/this/true/that` that_path(my_bool: false) # => `/this/false/that` ``` fixes: #42280 Co-authored-by: Ryuta Kamizono <kamipo@gmail.com>
- Loading branch information
Showing
3 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters