Default relative_url_root to ENV["RAILS_RELATIVE_URL_ROOT"]. Fixes #3365
This commit is contained in:
parent
c046660328
commit
5266eb9f61
|
@ -19,8 +19,9 @@ module ActionMailer
|
|||
options.stylesheets_dir ||= paths["public/stylesheets"].first
|
||||
|
||||
# make sure readers methods get compiled
|
||||
options.asset_path ||= app.config.asset_path
|
||||
options.asset_host ||= app.config.asset_host
|
||||
options.asset_path ||= app.config.asset_path
|
||||
options.asset_host ||= app.config.asset_host
|
||||
options.relative_url_root ||= app.config.relative_url_root
|
||||
|
||||
ActiveSupport.on_load(:action_mailer) do
|
||||
include AbstractController::UrlFor
|
||||
|
|
|
@ -4,7 +4,7 @@ module AbstractController
|
|||
|
||||
included do
|
||||
config_accessor :asset_host, :asset_path, :assets_dir, :javascripts_dir,
|
||||
:stylesheets_dir, :default_asset_host_protocol
|
||||
:stylesheets_dir, :default_asset_host_protocol, :relative_url_root
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,6 +31,7 @@ module ActionController
|
|||
# make sure readers methods get compiled
|
||||
options.asset_path ||= app.config.asset_path
|
||||
options.asset_host ||= app.config.asset_host
|
||||
options.relative_url_root ||= app.config.relative_url_root
|
||||
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
include app.routes.mounted_helpers
|
||||
|
|
|
@ -9,7 +9,7 @@ module Rails
|
|||
:cache_classes, :cache_store, :consider_all_requests_local,
|
||||
:dependency_loading, :filter_parameters,
|
||||
:force_ssl, :helpers_paths, :logger, :log_tags, :preload_frameworks,
|
||||
:reload_plugins, :secret_token, :serve_static_assets,
|
||||
:relative_url_root, :reload_plugins, :secret_token, :serve_static_assets,
|
||||
:ssl_options, :static_cache_control, :session_options,
|
||||
:time_zone, :whiny_nils, :railties_order, :all_initializers
|
||||
|
||||
|
@ -37,6 +37,7 @@ module Rails
|
|||
@cache_store = [ :file_store, "#{root}/tmp/cache/" ]
|
||||
@railties_order = [:all]
|
||||
@all_initializers = []
|
||||
@relative_url_root = ENV["RAILS_RELATIVE_URL_ROOT"]
|
||||
|
||||
@assets = ActiveSupport::OrderedOptions.new
|
||||
@assets.enabled = false
|
||||
|
|
|
@ -478,6 +478,15 @@ module ApplicationTests
|
|||
assert_match 'src="//example.com/assets/rails.png"', File.read("#{app_path}/public/assets/image_loader.js")
|
||||
end
|
||||
|
||||
test "asset paths should use RAILS_RELATIVE_URL_ROOT by default" do
|
||||
ENV["RAILS_RELATIVE_URL_ROOT"] = "/sub/uri"
|
||||
|
||||
app_file "app/assets/javascripts/app.js.erb", 'var src="<%= image_path("rails.png") %>";'
|
||||
add_to_config "config.assets.precompile = %w{app.js}"
|
||||
precompile!
|
||||
|
||||
assert_match 'src="/sub/uri/assets/rails.png"', File.read("#{app_path}/public/assets/app.js")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
Loading…
Reference in New Issue