简体   繁体   中英

Possible to change RAILS_ROOT?

before the moans and groans, my client is using Godaddy to host his rails app. 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.

www.yoursite.com/myrailsapp

I have tried putting this in the environment.rb

Basically all the links is suppose to work like this:

www.yoursite.com/link1

but instead it becomes:

www.yoursite.com/myrailsapp/link1

Is there any way to get the RAILS_ROOT to point at the actual rails root app directory?

I don't believe this is a RAILS_ROOT issue, but more of a VirtualHost issue. The domain isn't setting the DocumentRoot to your Rails public directory.

RAILS_ROOT is simply defined in 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. 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.

There are several options to get around this depending on what the application is deployed under (Passenger, FastCGI, mongrel, etc.). 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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