Skip to content

feat(global-edition): autoinclude GE path prefix in Rails generated URLs#73059

Merged
artem-vavilov merged 3 commits into
stagingfrom
global-edition-routing-patch
Jun 8, 2026
Merged

feat(global-edition): autoinclude GE path prefix in Rails generated URLs#73059
artem-vavilov merged 3 commits into
stagingfrom
global-edition-routing-patch

Conversation

@artem-vavilov

@artem-vavilov artem-vavilov commented Jun 4, 2026

Copy link
Copy Markdown
Member

Automatically adds the active Global Edition path prefix to Rails generated URLs.

Controllers, views, and helpers already get this behavior through request.script_name, which is set by Middleware::GlobalEdition. However, route helpers can also be called from places without direct access to the request object, such as models or background logic:

# Generates a URL pointing to the course, optionally including a section ID as a query parameter.
#
# @param section_id [Integer, String, nil] The ID of the section to include in the query parameter. Defaults to nil.
# @return [String] The URL for the course, which may include a section ID query parameter.
def link(section_id: nil)
course_path(self, section_id:)
end

This change makes generated paths respect the active Global Edition region for the current request through Cdo::GlobalEdition.current_region, while preserving any explicitly provided script_name. For example:

Rails.application.routes.url_helpers.home_path
# => '/home'

Cdo::GlobalEdition.current_region = 'in'
Rails.application.routes.url_helpers.home_path
# => '/in/en/home'

Cdo::GlobalEdition.current_region = 'in'
I18n.locale = 'hi-IN'
Rails.application.routes.url_helpers.home_path                     # => '/in/hi/home'
Rails.application.routes.url_helpers.home_path(script_name: '/la') # => '/la/home'
Rails.application.routes.url_helpers.home_path(script_name: nil)   # => '/home'

@artem-vavilov artem-vavilov requested review from a team and wilkie June 4, 2026 10:42

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2d7439fd8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/cdo/global_edition.rb

This comment was marked as resolved.

@artem-vavilov artem-vavilov force-pushed the global-edition-routing-patch branch from a2d7439 to ab2bf21 Compare June 4, 2026 21:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@artem-vavilov artem-vavilov force-pushed the global-edition-routing-patch branch from 0328b07 to a16fc5a Compare June 5, 2026 12:26
@artem-vavilov artem-vavilov merged commit 4b5d42d into staging Jun 8, 2026
8 checks passed
@artem-vavilov artem-vavilov deleted the global-edition-routing-patch branch June 8, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants