为什么在 Rails 目录结构中样式表和脚本与应用程序分开

发布于 2024-09-13 06:44:27 字数 143 浏览 2 评论 0原文

我一直不明白为什么样式表和脚本位于 ruby​​ on Rails 中的 /app 文件夹之外。将它们存放在远离 /app/public 文件夹中是否有好处?

感谢! 马特

I never understood why the stylesheets and scripts are outside the /app folder in ruby on rails. Is there benefits of housing them in the /public folder away from the /app?

Thank!
Matt

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

偏爱你一生 2024-09-20 06:44:27

在生产环境中,/app 由 Ruby 应用服务器提供服务,即 mongrel、thin、unicorn 等,而 /public 由网络服务器提供服务更好地提供静态内容,即 nginx。有时您还希望将 /public 解耦,由 CDN,即 Amazon S3。将这两个目录解耦可以在生产环境中提供更好的部署安排。

In production environment, /app is served by Ruby appserver, i.e mongrel, thin, unicorn, etc, while /public is served by a webserver that is better in serving static content, i.e nginx. Sometimes you would also want to decouple /public to be served by a CDN, i.e Amazon S3. Decoupling this two directory provides better deployment arrangement in production environment.

烛影斜 2024-09-20 06:44:27

/app 文件夹通常包含动态 数据,/public 文件夹包含静态 文件。这是为了缓存和性能而设计的。 Web 服务器可以将 /public 文件夹中的文件直接输出给用户,而无需额外的 Ruby 调用。它还可以缓存静态文件,为其设置各种标头等等。

The /app folder usually contains dynamic data, the /public folder contains static files. This was made for caching and performance. A Web-server can output files in the /public folder directly to the user, without additional Ruby calls. It also can cache static files, set various headers on them and so on.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文