Rails样式表未在heroku上加载(生产模式)

时间:2017-04-17 09:52:20

标签: css ruby-on-rails heroku

我的样式表停止在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

如果您有任何想法,请告诉我。感谢。

1 个答案:

答案 0 :(得分:0)

对本地计算机运行以下命令:

RAILS_ENV=production rake assets:precompile

然后推送所有生成的&清单文件到heroku。