Rails 5.2资产未在生产中正确加载

时间:2019-07-08 23:23:56

标签: ruby-on-rails heroku production

我正在为Rails项目使用wrapbootstarp模板,在开发中运行应用程序时将所有css和js文件移至供应商/资产,它正确加载了所有资产(css和js),但在heroku中显示空白页

我尝试手动预编译资产,但仍然显示空白页。奇怪的是资产已加载:

<link rel="stylesheet" media="all" href="/assets/application-95017034c76c900be6f5471a85b9cbc01136147254c81d0bb0b25ee5ea4795c7.css" data-turbolinks-track="reload" />
    <script src="/assets/application-aa7d1978d221c464c99b122177a647765fc068f540c747c6ebc14a1771a2b898.js" data-turbolinks-track="reload"></script>

这是我的application.js和application.css: js

//= require rails-ujs
//= require activestorage
//= require turbolinks
//= require_tree .

//= require js/jquery-3.2.1.min.js
//= require js/bootstrap.min.js
//= require js/owl.carousel.min.js
//= require js/wow.min.js
//= require js/waypoints.min.js
//= require js/jquery.counterup.min.js
//= require inc/lightbox/js/jquery.fancybox.pack.js
//= require inc/lightbox/js/lightbox.js
//= require js/fakeLoader.min.js
//= require js/scrolltopcontrol.js
//= require js/bootstrap-4-navbar.js
//= require js/jquery.magnific-popup.min.js
//= require slick/slick.min.js
//= require js/color-switcher.js
//= require js/color-switcher-active.js
//= require js/custom.js

css

 *= require_tree .
 *= require_self

 *= require css/bootstrap.min.css
 *= require fonts/css/fontawesome-all.min.css
 *= require css/animate.css
 *= require css/bootstrap-4-navbar.css
 *= require slick/slick.css
 *= require inc/lightbox/css/jquery.fancybox.css
 *= require css/owl.carousel.min.css
 *= require css/owl.theme.default.min.css
 *= require css/fakeLoader.css
 *= require css/magnific-popup.css
 *= require style.css
 *= require color/color-switcher.css
 *= require css/responsive.css

完整的服务器日志

2019-07-09T03:06:04.554365+00:00 heroku[web.1]: State changed from up to starting
2019-07-09T03:06:05.778974+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2019-07-09T03:06:05.789818+00:00 app[web.1]: === puma shutdown: 2019-07-09 03:06:05 +0000 ===
2019-07-09T03:06:05.789828+00:00 app[web.1]: - Goodbye!
2019-07-09T03:06:05.789925+00:00 app[web.1]: Exiting
2019-07-09T03:06:05.762376+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2019-07-09T03:06:05.885244+00:00 heroku[web.1]: Process exited with status 143
2019-07-09T03:06:08.816439+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 9411`
2019-07-09T03:06:18.069154+00:00 heroku[web.1]: State changed from starting to up
2019-07-09T03:07:30.326358+00:00 heroku[router]: at=info method=GET path="/" host=sfaai.herokuapp.com request_id=75acf86b-661c-4eb8-bc14-7a1f06668bac fwd="73.179.45.178" dyno=web.1 connect=1ms service=116ms status=200 bytes=28535 protocol=https
2019-07-09T03:07:30.222866+00:00 app[web.1]: => Booting Puma
2019-07-09T03:07:30.222890+00:00 app[web.1]: => Rails 5.2.3 application starting in production
2019-07-09T03:07:30.222892+00:00 app[web.1]: => Run `rails server -h` for more startup options
2019-07-09T03:07:30.222895+00:00 app[web.1]: Puma starting in single mode...
2019-07-09T03:07:30.222897+00:00 app[web.1]: * Version 3.12.1 (ruby 2.5.5-p157), codename: Llamas in Pajamas
2019-07-09T03:07:30.222899+00:00 app[web.1]: * Min threads: 5, max threads: 5
2019-07-09T03:07:30.222901+00:00 app[web.1]: * Environment: production
2019-07-09T03:07:30.222903+00:00 app[web.1]: * Listening on tcp://0.0.0.0:9411
2019-07-09T03:07:30.222905+00:00 app[web.1]: Use Ctrl-C to stop
2019-07-09T03:07:30.222921+00:00 app[web.1]: I, [2019-07-09T03:07:30.222725 #4]  INFO -- : [75acf86b-661c-4eb8-bc14-7a1f06668bac] Started GET "/" for 73.179.45.178 at 2019-07-09 03:07:30 +0000
2019-07-09T03:07:30.238573+00:00 app[web.1]: I, [2019-07-09T03:07:30.238463 #4]  INFO -- : [75acf86b-661c-4eb8-bc14-7a1f06668bac] Processing by PagesController#index as HTML
2019-07-09T03:07:30.268578+00:00 app[web.1]: I, [2019-07-09T03:07:30.268461 #4]  INFO -- : [75acf86b-661c-4eb8-bc14-7a1f06668bac]   Rendering pages/index.html.erb within layouts/application
2019-07-09T03:07:30.281799+00:00 app[web.1]: I, [2019-07-09T03:07:30.281698 #4]  INFO -- : [75acf86b-661c-4eb8-bc14-7a1f06668bac]   Rendered layouts/partials/_sliders.html.erb (4.7ms)
2019-07-09T03:07:30.284344+00:00 app[web.1]: I, [2019-07-09T03:07:30.284063 #4]  INFO -- : [75acf86b-661c-4eb8-bc14-7a1f06668bac]   Rendered layouts/partials/_about.html.erb (0.9ms)
2019-07-09T03:07:30.288207+00:00 app[web.1]: I, [2019-07-09T03:07:30.288138 #4]  INFO -- : [75acf86b-661c-4eb8-bc14-7a1f06668bac]   Rendered layouts/partials/_services.html.erb (1.6ms)
2019-07-09T03:07:30.294139+00:00 app[web.1]: I, [2019-07-09T03:07:30.294068 #4]  INFO -- : [75acf86b-661c-4eb8-bc14-7a1f06668bac]   Rendered layouts/partials/_doctors.html.erb (3.7ms)
2019-07-09T03:07:30.298777+00:00 app[web.1]: I, [2019-07-09T03:07:30.298711 #4]  INFO -- : [75acf86b-661c-4eb8-bc14-7a1f06668bac]   Rendered layouts/partials/_testimonials.html.erb (1.3ms)
2019-07-09T03:07:30.301639+00:00 app[web.1]: I, [2019-07-09T03:07:30.301574 #4]  INFO -- : [75acf86b-661c-4eb8-bc14-7a1f06668bac]   Rendered pages/index.html.erb within layouts/application (29.7ms)
2019-07-09T03:07:30.307812+00:00 app[web.1]: I, [2019-07-09T03:07:30.307741 #4]  INFO -- : [75acf86b-661c-4eb8-bc14-7a1f06668bac]   Rendered layouts/partials/_top_menu.html.erb (2.6ms)
2019-07-09T03:07:30.311383+00:00 app[web.1]: I, [2019-07-09T03:07:30.311315 #4]  INFO -- : [75acf86b-661c-4eb8-bc14-7a1f06668bac]   Rendered layouts/partials/_main_menu.html.erb (1.0ms)
2019-07-09T03:07:30.315240+00:00 app[web.1]: I, [2019-07-09T03:07:30.315173 #4]  INFO -- : [75acf86b-661c-4eb8-bc14-7a1f06668bac]   Rendered layouts/partials/_footer.html.erb (0.8ms)
2019-07-09T03:07:30.317914+00:00 app[web.1]: I, [2019-07-09T03:07:30.317846 #4]  INFO -- : [75acf86b-661c-4eb8-bc14-7a1f06668bac] Completed 200 OK in 78ms (Views: 51.3ms)```

1 个答案:

答案 0 :(得分:1)

您正在使用bodydisplay: none;标记样式。您不会在页面上看到任何内容,因为其中的内容是隐藏的。

如果您直接在CSS中添加了display: none;,只需将其删除即可。如果某种原因导致您选择使用CSS框架或其他JavaScript库,则需要弄清楚为什么将这种样式放置在body标签上。

当我使用Chrome检查器删除样式时,会看到该网站:

the visible site