Wrong root on image_tag, include_tags, etc
On my dev setup, generated routes are mysteriously pointing 开发者_开发技巧to my public www server.
[yields]
<script src="http://www.mysite.com//javascripts/prototype.js?1265304231" type="text/javascript"></script>
<script src="http://www.mysite.com//javascripts/effects.js?1265304231" type="text/javascript"></script>
<script src="http://www.mysite.com//javascripts/dragdrop.js?1265304231" type="text/javascript"></script>
<script src="http://www.mysite.com//javascripts/controls.js?1273647885" type="text/javascript"></script>
<script src="http://mysite.opzi.com//javascripts/application.js?1273611341" type="text/javascript"></script>
Where is this option set? Can't find it for the life of me.
One way this would happen is if you set ActionController::Base.asset_host
to point to your public server in environment.rb.
Just since no one has provided a way to troubleshoot this:
The problem is likely an extra slash in one of your configs. asset_host
is prepended to all asset tags generated programmatically, so using ERB:
<%= stylesheet_link_tag :defaults %>
will give you the equivalent of:
<%= "<link href='#{ActionController::Base.asset_host}/stylesheets/defaults.css' media='screen' rel='stylesheet' type='text/css' />" %>
To check the contents of asset_host
just print it out somewhere in one of your pages:
asset_host is set to: "<%= ActionController::Base.asset_host %>"
I would suspect you will get something back like http://www.mysite.com/
. The problem is the ending slash. It should rather be set to http://www.mysite.com
. Now it is just a matter of tracking down the setting in your configs. An easy way would just be to search for http://www.mysite.com/
in your source to find the relevant setting mighty fast!
If you want to override it just in the current process, you can set asset_host
to whatever you want:
ActionController::Base.asset_host = "http://www.mysite.com"
You should check your config/environment.rb
and config/environment/development.rb
files.
Look specifically for any asset_host
tags. From guides.rubyonrails.org:
asset_host provides a string that is prepended to all of the URL-generating helpers in AssetHelper. This is designed to allow moving all javascript, CSS, and image files to a separate asset host.
For more information, see http://guides.rubyonrails.org/configuring.html
In case you're using Facebooker, it might be callback_url setting in facebooker.yml config file that is affecting ActionController::Base.asset_host value and corrupting your routes.
精彩评论