diff options
author | José Valim <jose.valim@gmail.com> | 2011-12-12 09:14:48 -0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-12-12 09:14:48 -0800 |
commit | af308ff3762c1923e9a5ecdbf2fb8f102062d675 (patch) | |
tree | 43da85efd542743a07be3cd379071bae521a6679 | |
parent | c0466603288252a5db8a4d8cf0ca193004a542ea (diff) | |
parent | 5266eb9f611a114663c48eec0680b7050181d3de (diff) | |
download | rails-af308ff3762c1923e9a5ecdbf2fb8f102062d675.tar.gz rails-af308ff3762c1923e9a5ecdbf2fb8f102062d675.tar.bz2 rails-af308ff3762c1923e9a5ecdbf2fb8f102062d675.zip |
Merge pull request #3946 from pokonski/relative_root
Fix #3365. Default config.relative_url_root to ENV["RAILS_RELATIVE_URL_ROOT"].
-rw-r--r-- | actionmailer/lib/action_mailer/railtie.rb | 5 | ||||
-rw-r--r-- | actionpack/lib/abstract_controller/asset_paths.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/railtie.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/application/configuration.rb | 3 | ||||
-rw-r--r-- | railties/test/application/assets_test.rb | 9 |
5 files changed, 16 insertions, 4 deletions
diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index 444754d0e9..5c03a29f0f 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -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 diff --git a/actionpack/lib/abstract_controller/asset_paths.rb b/actionpack/lib/abstract_controller/asset_paths.rb index c2a6809f58..dd5f9a1942 100644 --- a/actionpack/lib/abstract_controller/asset_paths.rb +++ b/actionpack/lib/abstract_controller/asset_paths.rb @@ -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 diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb index de7b837ecc..cb2e2b17aa 100644 --- a/actionpack/lib/action_controller/railtie.rb +++ b/actionpack/lib/action_controller/railtie.rb @@ -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 diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 9e1a5be358..4b2afe3a28 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -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 diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index 392bef3fd1..a08ea77ff3 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -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 |