Skip to content
  • Jonathan Hefner's avatar
    93038baa
    Use routes.default_url_options in AC::Renderer env · 93038baa
    Jonathan Hefner authored
    When a host is not specified for an `ActionController::Renderer`'s env,
    the host and related options will now be derived from the routes'
    `default_url_options` and `ActionDispatch::Http::URL.secure_protocol`.
    
    For example, with:
    
      ```ruby
      Rails.application.default_url_options = { host: "rubyonrails.org" }
      Rails.application.config.force_ssl = true
      ```
    
    Before:
    
      ```ruby
      ApplicationController.renderer.render inline: "<%= blog_url %>"
      # => "http://example.org/blog"
      ```
    
    After:
    
      ```ruby
      ApplicationController.renderer.render inline: "<%= blog_url %>"
      # => "https://rubyonrails.org/blog"
      ```
    
    As a consequence, Action Text attachment URLs rendered in a background
    job (a la Turbo Streams) will now use `Rails.application.default_url_options`.
    
    Fixes #41795.
    Fixes hotwired/turbo-rails#54.
    Fixes hotwired/turbo-rails#155.
    93038baa
    Use routes.default_url_options in AC::Renderer env
    Jonathan Hefner authored
    When a host is not specified for an `ActionController::Renderer`'s env,
    the host and related options will now be derived from the routes'
    `default_url_options` and `ActionDispatch::Http::URL.secure_protocol`.
    
    For example, with:
    
      ```ruby
      Rails.application.default_url_options = { host: "rubyonrails.org" }
      Rails.application.config.force_ssl = true
      ```
    
    Before:
    
      ```ruby
      ApplicationController.renderer.render inline: "<%= blog_url %>"
      # => "http://example.org/blog"
      ```
    
    After:
    
      ```ruby
      ApplicationController.renderer.render inline: "<%= blog_url %>"
      # => "https://rubyonrails.org/blog"
      ```
    
    As a consequence, Action Text attachment URLs rendered in a background
    job (a la Turbo Streams) will now use `Rails.application.default_url_options`.
    
    Fixes #41795.
    Fixes hotwired/turbo-rails#54.
    Fixes hotwired/turbo-rails#155.
Loading