config.default_asset_host_protocol is ignored? #2980

Closed
kennyj opened this Issue Sep 11, 2011 · 10 comments

Comments

Projects
None yet
5 participants
@kennyj
Contributor

kennyj commented Sep 11, 2011

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

@arunagw

This comment has been minimized.

Show comment
Hide comment
@arunagw

arunagw Sep 11, 2011

Member

More description will help people to understand issue :-)

Member

arunagw commented Sep 11, 2011

More description will help people to understand issue :-)

@kennyj

This comment has been minimized.

Show comment
Hide comment
@kennyj

kennyj Sep 11, 2011

Contributor

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

Contributor

kennyj commented Sep 11, 2011

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

@jamestyj

This comment has been minimized.

Show comment
Hide comment
@jamestyj

jamestyj Sep 26, 2011

I'm hitting the same bug too.

I'm hitting the same bug too.

@kennyj

This comment has been minimized.

Show comment
Hide comment
@kennyj

kennyj Sep 27, 2011

Contributor

■ 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

Contributor

kennyj commented Sep 27, 2011

■ 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 added a commit to kennyj/rails that referenced this issue Oct 4, 2011

@kennyj

This comment has been minimized.

Show comment
Hide comment
@kennyj

kennyj Oct 4, 2011

Contributor

cc @guilleiguaran
I think that this issue related to e01aba1

Contributor

kennyj commented Oct 4, 2011

cc @guilleiguaran
I think that this issue related to e01aba1

@kennyj kennyj closed this Oct 4, 2011

@kennyj kennyj reopened this Oct 4, 2011

@josevalim josevalim closed this in db8db4a Oct 5, 2011

@josevalim

This comment has been minimized.

Show comment
Hide comment
@josevalim

josevalim Oct 5, 2011

Contributor

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.

Contributor

josevalim commented Oct 5, 2011

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

This comment has been minimized.

Show comment
Hide comment
@spastorino

spastorino Oct 5, 2011

Member

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

Member

spastorino commented Oct 5, 2011

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

@kennyj

This comment has been minimized.

Show comment
Hide comment
@kennyj

kennyj Oct 5, 2011

Contributor

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

Contributor

kennyj commented Oct 5, 2011

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

@kennyj

This comment has been minimized.

Show comment
Hide comment
@kennyj

kennyj Oct 5, 2011

Contributor

@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'
Contributor

kennyj commented Oct 5, 2011

@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

This comment has been minimized.

Show comment
Hide comment
@spastorino

spastorino Oct 5, 2011

Member

@kennyj cool

Member

spastorino commented Oct 5, 2011

@kennyj cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment