Rails Does Not Load Below Assets

Asked 1 years ago, Updated 1 years ago, 30 views

I created a simple app with rails, but I noticed that javascripts may or may not be loaded correctly.It was not read for the first time, and when I reloaded, javascript was loaded.

$rails reproduced the symptom and read the log, and one page looked like this:

Started GET "/customers/sign_up" for 127.0.0.1 at 2014-12-21 19:19:17 +0900
Processing by Customers::RegistrationsController #new as HTML
  Rate Load (0.2ms) SELECT "rates". * FROM "rates" ORDER BY "rates". "id" ASCLIMIT1
  CACHE(0.0ms) SELECT "rates".* FROM "rates" ORDER BY "rates". "id" ASCLIMIT1
  Rendered admin/_header.html.erb (3.3ms)
  Rendered customers/registrations/new.html.erb with in layouts/application (9.2ms)
  Rendered layouts/_footer.html.erb(0.0ms)
Completed 200 OK in 442ms (Views: 440.3ms | ActiveRecord: 0.2ms)

That's all, but if you reload it,

Started GET "/customers/sign_up" for 127.0.0.1 at 2014-12-21 19:20:05 +0900
Processing by Customers::RegistrationsController #new as HTML
  Rate Load (0.1ms) SELECT "rates". * FROM "rates" ORDER BY "rates". "id" ASCLIMIT1
  CACHE(0.0ms) SELECT "rates".* FROM "rates" ORDER BY "rates". "id" ASCLIMIT1
  Rendered admin/_header.html.erb (1.5ms)
  Rendered customers/registrations/new.html.erb with in layouts/application (8.5ms)
  Rendered layouts/_footer.html.erb(0.0ms)
Completed 200 OK in 403 ms (Views: 401.2 ms | ActiveRecord: 0.2 ms)

Started GET"/assets/metallic/components.css?body=1" for 127.0.0.1 at 2014-12-21 19:20:06+0900

Started GET"/assets/metallic/plugins.css?body=1" for 127.0.0.1 at 2014-12-21 19:20:06+0900

Started GET"/assets/metallic/default.css?body=1" for 127.0.0.1 at 2014-12-21 19:20:06+0900

The log continues below.

It reads /assets and below. Basically, I thought it would be read as a matter of course, but I don't know why this behavior occurs.Could someone please let me know?

javascript ruby-on-rails

2022-09-30 16:05

1 Answers

"Regarding the expression ""first time loading"", is it okay to think that it is flying on the link from another page?"(If you put the link directly into the browser address bar, the CSS will also load.)

If so, I think this is the Turbolinks feature of Rails.

For more information, read the Reference, but for faster speeds, the Turbolinks feature is turned on by default in Rails 4 and later.

This feature does not import the entire page when you click on a link, but replaces the one in the body tag, so you do not go back to the server to retrieve the CSS or JavaScript.


2022-09-30 16:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.