Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple config.asset_host assignment from rails: #415

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 29, 2017

  1. Decouple config.asset_host assignment from rails:

    - There is two way to set the asset_host in rails: `config.action_controller.asset_host=` and `config.asset_host=` (the latter being usefull to both set action_mailer/action_controller asset_host)
    - Opening this PR for two reasons:
      1. Getting the asset_host from `config.action_controller` currently works when the asset_host is defined using `config.asset_host` but I feel like this might be by chance:
        - When rails initialization process kicks in, the `action_controller.set_configs` initializer runs. A variable `options` is assigned and reference `config.action_controller`. The `options` variable get modified and by doing so modify the refernce to `config.action_controller` https://github.com/rails/rails/blob/1bee2fb600c07625b830afd33b43ead3364c9715/actionpack/lib/action_controller/railtie.rb#L50
      2. If a gem decide to set the asset_host automatically for any apps, the gem can do so inside an initializer.
         ```ruby
           initializer :set_asset_host do |app|
             app.config.asset_host = 'https://example.com'
           end
         ```
         This code won't have any effect in sprockets-rails and as a result any assets referenced inside css, i.e. (`.div { background-image: url('/assets/rails.png') }) will not be prefixed by the asset_host
    Edouard-chin committed Nov 29, 2017
    Configuration menu
    Copy the full SHA
    0ad1f7d View commit details
    Browse the repository at this point in the history