Skip to content
Browse files

Merge pull request #3946 from pokonski/relative_root

Fix #3365. Default config.relative_url_root to ENV["RAILS_RELATIVE_URL_ROOT"].
  • Loading branch information...
2 parents c046660 + 5266eb9 commit af308ff3762c1923e9a5ecdbf2fb8f102062d675 @josevalim josevalim committed Dec 12, 2011
View
5 actionmailer/lib/action_mailer/railtie.rb
@@ -19,8 +19,9 @@ class Railtie < Rails::Railtie
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
View
2 actionpack/lib/abstract_controller/asset_paths.rb
@@ -4,7 +4,7 @@ module AssetPaths
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
View
1 actionpack/lib/action_controller/railtie.rb
@@ -31,6 +31,7 @@ class Railtie < Rails::Railtie
# 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
View
3 railties/lib/rails/application/configuration.rb
@@ -9,7 +9,7 @@ class Configuration < ::Rails::Engine::Configuration
: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 @@ def initialize(*)
@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
View
9 railties/test/application/assets_test.rb
@@ -478,6 +478,15 @@ class ::PostsController < ActionController::Base; end
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

0 comments on commit af308ff

Please sign in to comment.
Something went wrong with that request. Please try again.