Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

config.default_asset_host_protocol is ignored? #2980

Closed
kennyj opened this Issue · 10 comments

5 participants

@kennyj
Collaborator

config.default_asset_host_protocol = :relative (actionpack/lib/sprockets/railtie.rb)
But, all assets(javascripts, stylesheets and images) used :request.

@arunagw
Collaborator

More description will help people to understand issue :-)

@kennyj
Collaborator

sorry, the enter key has been pressed before finishing writing.

@jamestyj

I'm hitting the same bug too.

@kennyj
Collaborator

■ First

$ rails new demo
$ cd demo
$ rails g scaffold Post title:string
$ RAILS_ENV=production bundle exec rake db:migrate
$ bundle exec rake assets:precompile
$ bundle exec rails s -e production

<head>
  <title>Demo</title>
  <link href="/assets/application-8af74128f904600e41a6e39241464e03.css" media="screen" rel="stylesheet" type="text/css" />
  <script src="/assets/application-a552e1db33b8be6a42eedf1261916f3c.js" type="text/javascript"></script>
  ...
</head>

■ Next

edit config/environments/production.rb
=> config.action_controller.asset_host = "assets.example.com" (without "http://")

$ bundle exec rails s -e production

<head>
  <title>Demo</title>
  <link href="http://assets.example.com/assets/application-8af74128f904600e41a6e39241464e03.css" media="screen" rel="stylesheet" type="text/css" />
  <script src="http://assets.example.com/assets/application-a552e1db33b8be6a42eedf1261916f3c.js" type="text/javascript"></script>
  ...
</head>

Above script tag's src attribute is bad.
I want a url without "http:" (because of js and img default protocol is :relative). But, default_protocol method (in actionpack/lib/action_view/asset_paths.rb) is return "request".

expected:

<head>
  <title>Demo</title>
  <link href="http://assets.example.com/assets/application-8af74128f904600e41a6e39241464e03.css" media="screen" rel="stylesheet" type="text/css" />
  <script src="//assets.example.com/assets/application-a552e1db33b8be6a42eedf1261916f3c.js" type="text/javascript"></script>
  ...
</head>

I think that
config.default_asset_host_protocol = :relative (actionpack/lib/sprockets/railtie.rb)
seem to not perform well

@kennyj kennyj referenced this issue from a commit in kennyj/rails
@kennyj kennyj fixed #2980. I think that this problem is 2 pieces. Testcase problem …
…and config missing problem.
cbc9d25
@kennyj
Collaborator

cc @guilleiguaran
I think that this issue related to e01aba1

@kennyj kennyj closed this
@kennyj kennyj reopened this
@josevalim josevalim closed this in db8db4a
@josevalim
Owner

This should be fixed in the commit above. Notice the proper configuration option is config.action_controller.default_asset_host_protocol and not config.default_asset_host_protocol.

@spastorino
Owner

@kennyj @jamestyj can you guys test current 3-1-stable code and let us know if it's ok?

@kennyj
Collaborator

@spastorino
OK :-) I will test it after the work.

@kennyj
Collaborator

@spastorino
I guess it's work fine on 3-1-stable branch.

BTW
I tested it on my above demo project, and I edited Gemfile

gem 'rails', :git => 'git://github.com/rails/rails.git', :branch => '3-1-stable'
@spastorino
Owner

@kennyj cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.