【发布时间】:2017-04-17 09:52:19
【问题描述】:
我的样式表停止在 heroku 上加载(仅限生产模式,在本地一切正常)。
这是heroku日志上的错误信息
ActionController::RoutingError (No route matches [GET] "/assets/application-cdff05ced6e18e533fc2f71d065b63f48ce16d3045406917ed854476a7eb1702.css")
确实当我跑步时
heroku rake assets:precompile
其他文件被预编译
/app/vendor/bundle/ruby/2.2.0/gems/rb-readline-0.5.3/lib/readline.rb:458: warning: already initialized constant Readline::HISTORY
/app/vendor/bundle/ruby/2.2.0/gems/rb-readline-0.5.3/lib/readline.rb:486: warning: already initialized constant Readline::FILENAME_COMPLETION_PROC
/app/vendor/bundle/ruby/2.2.0/gems/rb-readline-0.5.3/lib/readline.rb:517: warning: already initialized constant Readline::USERNAME_COMPLETION_PROC
/app/vendor/bundle/ruby/2.2.0/gems/rb-readline-0.5.3/lib/readline.rb:523: warning: already initialized constant Readline::VERSION
I, [2017-04-17T09:41:44.957818 #4] INFO -- : Writing /app/public/assets/application-f295a8fe23711032f76515a85070c9a4a7195e35bb2ea56572a87cab10734aef.js
I, [2017-04-17T09:41:44.958361 #4] INFO -- : Writing /app/public/assets/application-f295a8fe23711032f76515a85070c9a4a7195e35bb2ea56572a87cab10734aef.js.gz
I, [2017-04-17T09:41:50.103993 #4] INFO -- : Writing /app/public/assets/application-e86e4356a42c5e1f39646b26c890239ee4734ecd3a9a5e4214aea2a68d0e4509.css
I, [2017-04-17T09:41:50.104211 #4] INFO -- : Writing /app/public/assets/application-e86e4356a42c5e1f39646b26c890239ee4734ecd3a9a5e4214aea2a68d0e4509.css.gz
关于这个主题有很多帖子,现在这是我的 production.rb 文件中的内容,经过几次不成功的其他尝试。
config.serve_static_files = true
config.assets.initialize_on_precompile = false
config.assets.compile = true
如果您有任何想法,请告诉我。谢谢。
【问题讨论】:
-
在 production.rb 中设置 config.assets.compile = false 并尝试相同的步骤。由于上述配置,我猜每次加载网站时都会发生预编译。
标签: css ruby-on-rails heroku