简体   繁体   English

可以更改RAILS_ROOT吗?

[英]Possible to change RAILS_ROOT?

before the moans and groans, my client is using Godaddy to host his rails app. 在抱怨和吟之前,我的客户正在使用Godaddy托管他的rails应用程序。 I have managed to get the app working for him, but Godaddy uses a sym link to point to the app which appends the root of the website ex. 我设法使该应用程序为他工作,但是Godaddy使用符号链接指向该应用程序,该应用程序附加了网站ex的根目录。

www.yoursite.com/myrailsapp www.yoursite.com/myrailsapp

I have tried putting this in the environment.rb 我试过将它放在environment.rb中

Basically all the links is suppose to work like this: 基本上所有的链接都应该像这样工作:

www.yoursite.com/link1 www.yoursite.com/link1

but instead it becomes: 但是它变成:

www.yoursite.com/myrailsapp/link1 www.yoursite.com/myrailsapp/link1

Is there any way to get the RAILS_ROOT to point at the actual rails root app directory? 有什么办法让RAILS_ROOT指向实际的rails根应用目录?

I don't believe this is a RAILS_ROOT issue, but more of a VirtualHost issue. 我不认为这是RAILS_ROOT问题,而更多是VirtualHost的问题。 The domain isn't setting the DocumentRoot to your Rails public directory. 该域未将DocumentRoot设置为您的Rails公共目录。

RAILS_ROOT is simply defined in boot.rb. RAILS_ROOT是在boot.rb中简单定义的。 Although it's not expected you should have to change it, nothing is stopping you. 尽管不期望您必须进行更改,但没有什么可以阻止您。 It's typically near the very start of the file, right after the "don't change this" plea, and looks something like: 它通常在文件的开头附近,紧接在“不要更改此”请求之后,看起来像:

RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)

As Garrett mentioned this is definitely a VirtualHost issue. 正如Garrett所说,这绝对是VirtualHost问题。 RAILS_ROOT is a directory pointer to the location of the application in the file system on the server not the location in the URL. RAILS_ROOT是目录指针,指向应用程序在服务器上文件系统中的位置,而不是URL中的位置。

There are several options to get around this depending on what the application is deployed under (Passenger, FastCGI, mongrel, etc.). 有多种方法可以解决此问题,具体取决于应用程序的部署对象(Passenger,FastCGI,mongrel等)。 What you want to look for is how to setup you app to function in the subdirectory of your domain. 您要查找的是如何设置您的应用以使其在域的子目录中运行。

would this work: 这将工作:

RAILS_ROOT = "/home/#{File.dirname( FILE )}/.." unless defined?(RAILS_ROOT) RAILS_ROOT = “/家/#{File.dirname(FILE)} / ..”,除非定义?(RAILS_ROOT)

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

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