简体   繁体   English

Rails资产管道路径问题

[英]Rails Asset Pipeline Path Issue

I have a Rails app running on a shared web host under a folder in my root direction called 'mintrus-ror/'. 我的根方向上有一个名为“ mintrus-ror /”的文件夹下的共享Web主机上运行着Rails应用程序。 There is a symbolic link 'public_html/' that points to 'mintrus-ror/public/'. 有一个符号链接“ public_html /”指向“ mintrus-ror / public /”。 My Rails app loads in the browser but the stylesheets don't load. 我的Rails应用程序已在浏览器中加载,但样式表未加载。 Looking at the rendered source I noticed the assets path it is using is '/mintrus-ror/assets/application.css'. 在查看渲染的源时,我注意到它正在使用的资产路径为“ /mintrus-ror/assets/application.css”。 I am trying to figure out how to change it so it does not include the 'mintrus-ror/' directory in the assets path. 我试图弄清楚如何更改它,以便它在资产路径中不包含“ mintrus-ror /”目录。 Any ideas? 有任何想法吗?

You can try playing with the config.assets.manifest configuration option in config/environments/production.rb . 您可以尝试使用config/environments/production.rbconfig.assets.manifest配置选项。 There are other variables that influence this, one being the web server configuration. 还有其他影响此的变量,其中一个是Web服务器配置。 I've got no recent (less than six years ago) experience with shared hosts, but I've read that on some systems, you can edit the .htaccess file. 我最近(不到六年前)没有使用共享主机的经验,但是我已经读到在某些系统上可以编辑.htaccess文件。

I also presume that you're running in production mode and have previously compiled the assets with rake assets:precompile during your deployment step. 我还假设您正在生产模式下运行,并且之前在部署步骤中已使用rake assets:precompile编译了资产。 Capistrano does this automatically when the asset pipeline integration is turned on. 打开资产管道集成后,Capistrano会自动执行此操作。

The Rails Guide on the Asset Pipeline may be useful. 资产管道上的Rails指南可能会有用。

Your best bet may be to host on Heroku. 您最好的选择是在Heroku上托管。 It's free for small sites and a lot less hassle. 它对于小型网站是免费的,而且麻烦更少。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM