Rails image_tag 正在我的生产服务器上查找资产!
我读到,通过设置 ActionController::Base.asset_host,您可以控制 Rails 查找资产的位置。但是,默认情况下,Rails 应该查看“/public/...”,
不知何故,我的 Rails 应用程序知道在开发模式下查看我的生产地址,并且我没有在任何地方设置 ActionController::Base.asset_host 。我不确定在哪里可以找到这些信息。还有其他地方可以设置吗?我不认为我的部署配方应该与它有任何关系...
<%= image_tag 'my_logo.png' %>
导致 Rails 检查我的生产服务器中的文件。与样式表相同。
I read that by setting ActionController::Base.asset_host, you can control where rails looks for assets. However, by default Rails should look in '/public/...'
Somehow my Rails app knows to look at my production address when in development mode and I have not set ActionController::Base.asset_host anywhere. I am not sure where it is finding this information. Is there anywhere else this can be set? I don't think my deploy recipes should have anything to do with it...
<%= image_tag 'my_logo.png' %>
causes Rails to check my production server for the file. Same with stylesheets.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太确定 Rails 如何知道寻找我的生产域。我在代码中几乎所有地方都删除了它。根据文档,“默认情况下,Rails 链接到这些资产在公共文件夹中的当前主机上”,但我不太确定这意味着什么。为了防止这种情况再次成为问题并允许进行一些灵活的配置,我将资产主机域添加到我的环境配置中。我现在有这样的想法:
现在一切都很好。仍然不知道 Rails 如何知道查看我的生产域。
I am not quite sure how Rails knew to look for my production domain. I removed it almost everywhere in my code. According to the docs, "By default, Rails links to these assets on the current host in the public folder" but I am not quite sure what that means. To prevent this from ever being an issue again and to allow some flexible configuration, I added asset host domains to my environment configuration. I now have something like:
Everything works great now. Still don't know how Rails knew to look at my production domain.