我在 Rails 应用程序中加载 CSS 时遇到问题。我在两台机器上提取了相同的存储库。
在一台机器上,CSS 文件已正确加载。当我转到这台机器上的一个页面时,我在终端中得到以下信息:
Started GET "/" for 127.0.0.1 at 2013-03-06 19:03:32 -0500
Processing by HomeController#show as HTML
Compiled collaborators.css (6ms) (pid 862)
Compiled home.css (145ms) (pid 862)
Compiled patents.css (0ms) (pid 862)
Compiled projects.css (64ms) (pid 862)
Compiled users.css (2ms) (pid 862)
Compiled application.css (308ms) (pid 862)
Compiled jquery.js (3ms) (pid 862)
Compiled jquery_ujs.js (0ms) (pid 862)
Compiled collaborators.js (129ms) (pid 862)
Compiled home.js (0ms) (pid 862)
Compiled jquery.1.8.2.js (5ms) (pid 862)
Compiled patents.js (186ms) (pid 862)
Compiled projects.js (0ms) (pid 862)
Compiled users.js (0ms) (pid 862)
Compiled application.js (1185ms) (pid 862)
User Load (1.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = 13945 LIMIT 1
Rendered layouts/_header.html.erb (95.7ms)
Rendered home/show.html.erb within layouts/application (2088.1ms)
Completed 200 OK in 2114ms (Views: 2104.9ms | ActiveRecord: 8.3ms)
当我在另一台机器上加载相同的页面时,我在终端中得到以下信息
Started GET "/" for 127.0.0.1 at 2013-03-06 19:31:19 -0500
Processing by HomeController#show as HTML
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 460 LIMIT 1
Rendered layouts/_header.html.erb (3.4ms)
Rendered home/show.html.erb within layouts/application (5.8ms)
Completed 200 OK in 11ms (Views: 10.7ms | ActiveRecord: 0.3ms)
但是没有一个 CSS 可以编译。它也不会显示在浏览器中。可能是什么问题呢?
更新:我在第二台机器上运行了 rake assets:precompile 并且它有效。但是,删除 public/assets 文件夹使其无法正常工作。这意味着它不是实时编译。知道为什么吗?