Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config.default_asset_host_protocol is ignored? #2980

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

config.default_asset_host_protocol is ignored? #2980

kennyj opened this issue Sep 11, 2011 · 10 comments

Comments

@kennyj
Copy link
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
Copy link
Member

arunagw commented Sep 11, 2011

More description will help people to understand issue :-)

@kennyj
Copy link
Contributor Author

kennyj commented Sep 11, 2011

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

@jamestyj
Copy link

I'm hitting the same bug too.

@kennyj
Copy link
Contributor Author

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
Copy link
Contributor Author

kennyj commented Oct 4, 2011

cc @guilleiguaran
I think that this issue related to e01aba1

@kennyj kennyj closed this as completed Oct 4, 2011
@kennyj kennyj reopened this Oct 4, 2011
@josevalim
Copy link
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.

@spastorino
Copy link
Contributor

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

@kennyj
Copy link
Contributor Author

kennyj commented Oct 5, 2011

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

@kennyj
Copy link
Contributor Author

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
Copy link
Contributor

@kennyj cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants