加载公共/资产中的.css文件时,Rails 3.1 404错误 [英] Rails 3.1 404 Error when loading .css files that are present in public/assets

查看:81
本文介绍了加载公共/资产中的.css文件时,Rails 3.1 404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个已经在开发中运行很长时间的应用程序,最近又切换到在生产环境中运行它以更好地进行测试.资产不再加载,因此应用程序的整体外观受到了破坏.

I've got an application I've been running in development for a long time, and recently switched to running it in production to better test things out. Assets are no longer loading, so the entire look of the application is wrecked.

我在控制台中看到这样的错误:

I see errors like this in console:

cache: [GET /assets/login-b5cc6c1d02b7c2fe3fd9e365a0d6ff82.css] miss
cache: [GET /assets/main-9f54f3726daba54b6104bfa715be64d7.css] miss

如果我继续登录:

cache: [GET /] miss
---------------------- authorize user -------------------
cache: [GET /assets/login-b5cc6c1d02b7c2fe3fd9e365a0d6ff82.css] miss
---------------------- authorize user -------------------
cache: [GET /assets/main-9f54f3726daba54b6104bfa715be64d7.css] miss
------------ session create --------------
cache: [POST /login] invalidate, pass
---------------------- authorize user -------------------
cache: [GET /dashboard] miss
---------------------- authorize user -------------------
cache: [GET /assets/application-e0afa69f51ff7ce18d7e271410c28b9b.css] miss
---------------------- authorize user -------------------
cache: [GET /assets/application-58091a539ae6d50655f0588d22469022.js] miss
---------------------- authorize user -------------------
cache: [GET /assets/calendar/calendar_icon-cdfb05f267f65ad534496ca12ef7625d.png] miss
---------------------- authorize user -------------------
cache: [GET /assets/find-5cf3fb7806da54cfe899a8948601fac3.png] miss

如果我公开"公共/资产,那么所有这些带有正确指纹的文件都在那里.我已经删除了目录,重新编译了资产,删除了tmp/cache目录,所有这些仍然在控制台中显示为未命中,而在Web控制台中显示为404.

If I 'ls' public/assets, all these files with the correct fingerprint are there. I've deleted the directory, recompiled assets, deleted the tmp/cache directory, and these all still show up as misses in console and 404 in web console.

也: 最初,该应用程序是使用Rails 3.1.0编写的,我曾尝试过3.1.2、3.1.3和3.2.1,但该问题在所有版本中仍然存在.

ALSO: Initially the app was written with Rails 3.1.0, I've tried on 3.1.2, 3.1.3, and 3.2.1 and the issues persist through all versions.

让我知道我可以提供哪些信息以帮助您.谢谢您的想法!

Let me know what information I can provide to assist. Thank you for your thoughts!

推荐答案

您可能需要编译生产中的资产:<app root>/rake assets:precompilebundle exec(如果需要).

You may need to compile the assets in production: <app root>/rake assets:precompile or bundle exec if you need that.

这是

Here is a post I found useful when I ran into this issue.

这篇关于加载公共/资产中的.css文件时,Rails 3.1 404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆