Twitter bootstrap 未在生产Rails中正确预编译
在Rails 4中,我遇到了一个问题,即引导中的图标没有被正确预编译。生成以下内容:Twitter bootstrap 未在生产Rails中正确预编译,twitter-bootstrap,heroku,ruby-on-rails-4,Twitter Bootstrap,Heroku,Ruby On Rails 4,在Rails 4中,我遇到了一个问题,即引导中的图标没有被正确预编译。生成以下内容: started GET "/assets/glyphicons-halflings-white-ed38e147e3f6e976c0a7ad59e4d628f3.png" for 127.0.0.1 at 2014-01-13 18:41:25 -0500 Started GET "/assets/glyphicons-halflings-white-ed38e147e3f6e976c0a7a
started GET "/assets/glyphicons-halflings-white-ed38e147e3f6e976c0a7ad59e4d628f3.png" for 127.0.0.1 at 2014-01-13 18:41:25 -0500
Started GET "/assets/glyphicons-halflings-white-ed38e147e3f6e976c0a7ad59e4d628f3.png" for 127.0.0.1 at 2014-01-13 18:41:25 -0500
Processing by ApplicationController#routing_error as PNG
Processing by ApplicationController#routing_error as PNG
Parameters: {"path"=>"assets/glyphicons-halflings-white-ed38e147e3f6e976c0a7ad59e4d628f3"}
Parameters: {"path"=>"assets/glyphicons-halflings-white-ed38e147e3f6e976c0a7ad59e4d628f3"}
Rendered public/404.html (0.3ms)
Rendered public/404.html (0.3ms)
Completed 404 Not Found in 17ms (Views: 3.4ms | ActiveRecord: 8.0ms)
Completed 404 Not Found in 17ms (Views: 3.4ms | ActiveRecord: 8.0ms)
它在开发中运行良好。如果我在production.rb中设置了config.assets.compile=true
,它似乎工作得很好——但我知道基于这个问题,这是非常糟糕的:
在Rails 3.2中,这不是我的问题
任何帮助都将不胜感激 添加
config.assets.precompile += [
'glyphicons-halflings.png',
'glyphicons-halflings-white.png'
]
在我的application.rb中修复了这个问题
我不知道为什么Rails 4和Rails 3.2需要这样做?我在将应用程序从Rails 3.2升级到4时遇到了同样的问题 制作应用程序托管在Heroku上 Rails 3.2中的一切都很好 然而,在Rails4中,Glyphs在Dev中显示得很好,但在生产中却没有。浏览器控制台的快速检查显示404,因为资产路径错误 就我而言,我需要
config.assets.precompile += [
'twitter/bootstrap/glyphicons-halflings.png',
'twitter/bootstrap/glyphicons-halflings-white.png'
]
您好cman77,谢谢您发布此答案!这对我很有用。你能解释一下为什么要包含PNG文件,更重要的是,你是如何知道要包含PNG的?我只看到由预编译生成的
svg
、eot
、woff
和ttf
文件。