How to find out the reason why Ruby on Rails does not load the styles?

0 like 0 dislike
5 views
I'm trying to pack RoR project in Docker using docker-compose. The project was started but not loaded styles. In the logs this:
I, [2019-01-13T05:25:34.400480 #1] INFO -- : Started GET "/body/list/all" for 172.23.0.1 at 2019-01-13 05:25:34 +0000 I, [2019-01-13T05:25:34.406057 #1] INFO -- : Processing by PublicBodyController#list as HTML I, [2019-01-13T05:25:34.481372 #1] INFO -- : Rendered public_body/_body_listing.html.erb (1.2 ms) I, [2019-01-13T05:25:34.485731 #1] INFO -- : Rendered public_body/_alphabet.html.erb (3.5 ms) I, [2019-01-13T05:25:34.493234 #1] INFO -- : Rendered public_body/_list_sidebar_extra.html.erb (1.0 ms) I, [2019-01-13T05:25:34.493418 #1] INFO -- : Rendered public_body/list.html.erb within layouts/default (14.5 ms) I, [2019-01-13T05:25:34.494712 #1] INFO -- : Rendered layouts/_favicon.html.erb (0.4 ms) I, [2019-01-13T05:25:34.496835 #1] INFO -- : Rendered general/_responsive_stylesheets.html.erb (0.8 ms) I, [2019-01-13T05:25:34.497232 #1] INFO -- : Rendered general/_stylesheet_includes.html.erb (1.9 ms) I, [2019-01-13T05:25:34.498290 #1] INFO -- : Rendered general/_opengraph_tags.html.erb (0.4 ms) I, [2019-01-13T05:25:34.499673 #1] INFO -- : Rendered lib/themes/alavetelitheme/lib/views/general/_before_head_end.html.erb (0.6 ms) I, [2019-01-13T05:25:34.510512 #1] INFO -- : Rendered general/_locale_switcher.html.erb (0.2 ms) I, [2019-01-13T05:25:34.511186 #1] INFO -- : Rendered general/_log_in_bar.html.erb (0.3 ms) I, [2019-01-13T05:25:34.523354 #1] INFO -- : Rendered general/_nav_items.html.erb (0.9 ms) I, [2019-01-13T05:25:34.523524 #1] INFO -- : Rendered general/_responsive_topnav.html.erb (11.7 ms) I, [2019-01-13T05:25:34.523657 #1] INFO -- : Rendered general/_responsive_header.html.erb (14.2 ms) I, [2019-01-13T05:25:34.525045 #1] INFO -- : Rendered general/_responsive_credits.html.erb (0.2 ms) I, [2019-01-13T05:25:34.529978 #1] INFO -- : Rendered general/_responsive_footer.html.erb (5.7 ms) I, [2019-01-13T05:25:34.531204 #1] INFO -- : Rendered lib/themes/alavetelitheme/lib/views/general/_before_body_end.html.erb (0.5 ms) I, [2019-01-13T05:25:34.531496 #1] INFO -- : Completed 200 OK in 125ms (Views: 37.4 ms | ActiveRecord: 66.1 ms) I, [2019-01-13T05:25:34.546144 #1] INFO -- : Started GET "/stylesheets/responsive/application.css" for 172.23.0.1 at 2019-01-13 05:25:34 +0000 I, [2019-01-13T05:25:34.551177 #1] INFO -- : Processing by GeneralController#not_found as CSS I, [2019-01-13T05:25:34.551243 #1] INFO -- : Parameters: {"path"=>"stylesheets/responsive/application"} I, [2019-01-13T05:25:34.552297 #1] INFO -- : Completed 404 Not Found in 1ms (ActiveRecord: 0.0 ms) I, [2019-01-13T05:25:34.554729 #1] INFO -- : Started GET "/javascripts/application.js" for 172.23.0.1 at 2019-01-13 05:25:34 +0000 I, [2019-01-13T05:25:34.559508 #1] INFO -- : Processing by GeneralController#not_found as JS I, [2019-01-13T05:25:34.559613 #1] INFO -- : Parameters: {"path"=>"javascripts/application"} I, [2019-01-13T05:25:34.560663 #1] INFO -- : Completed 404 Not Found in 1ms (ActiveRecord: 0.0 ms) I, [2019-01-13T05:25:34.563017 #1] INFO -- : Started GET "/stylesheets/responsive/print.css" for 172.23.0.1 at 2019-01-13 05:25:34 +0000 I, [2019-01-13T05:25:34.567878 #1] INFO -- : Processing by GeneralController#not_found as CSS I, [2019-01-13T05:25:34.567976 #1] INFO -- : Parameters: {"path"=>"stylesheets/responsive/print"} I, [2019-01-13T05:25:34.569313 #1] INFO -- : Completed 404 Not Found in 1ms (ActiveRecord: 0.0 ms) I, [2019-01-13T05:25:34.593278 #1] INFO -- : Started GET "/images/favicon.ico" for 172.23.0.1 at 2019-01-13 05:25:34 +0000 I, [2019-01-13T05:25:34.597898 #1] INFO -- : Processing by GeneralController#not_found as I, [2019-01-13T05:25:34.597971 #1] INFO -- : Parameters: {"path"=>"images/favicon"} I, [2019-01-13T05:25:34.598964 #1] INFO -- : Completed 404 Not Found in 1ms (ActiveRecord: 0.0 ms)

Although the files are there on which he complains are present.
If I deploy using vagrant the same project, then everything works fine.
by | 5 views

4 Answers

0 like 0 dislike
You need to perform precompiling assets,
then refresh the page with Ctrl-F5 to picked up the way of new style files. You can also restart the browser. In DevTools in the Network tab, we need to look at what ways there is an appeal to the styles.
Generally, it is difficult to guess without the code. If you do not help the above, assume that the case in the Gemfile file or initialization of the framework.
by
0 like 0 dislike
Vargrant You have most likely configured for development, and trying to run Docker in production. Ruby slow for razdachi assets, so rails by default in production they are not handing out, hoping that it will make nginx.

So you can either add nginx in Docker, or set serve_static_assets = true in production.rb

In addition you need to ensure that all assets are compiled, those who are not add to assets.rb initializer
by
0 like 0 dislike
Try the old-fashioned way capistrano nginx first you understand how it all works, then packaged in docker. Or do not worry and find DevOps.
\rhabrahabr.ru/post/240025 to help me in my time really helped.
by
0 like 0 dislike
You can use 2 options:

First: compiling assets prior to Assembly and packing `public/assets` in the image. And then that folder as a volume to hang in the container to nginx and write the appropriate config for nginx

Second: compiling assets in the container (to include servse_static_assets in the rails) and configure the caching of assets on the web server.
by
110,608 questions
257,186 answers
0 comments
28,741 users