Forum: Ruby on Rails RAILS_ROOT

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ben M. (Guest)
on 2006-02-20 09:43
(Received via mailing list)
I just replied to someone about using send_file and while I was testing
my solution I
figured out that the controllers "current working dir" appears to be the
root of the app.

Then I saw a reply that Ezra sent to someone where he used RAILS_ROOT
and I thought "duh,
I've seen that before... shoulda used that".

But, when I had an action print out RAILS_ROOT it's
"./script/../config/..". I'm probably
being dense here, but what, why, huh? What does that mean and why isn't
RAILS_ROOT the
full system path to the app?

b
Ezra Z. (Guest)
on 2006-02-20 10:32
(Received via mailing list)
On Feb 19, 2006, at 11:44 PM, Ben M. wrote:

> does that mean and why isn't RAILS_ROOT the full system path to the
> app?
>
> b
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

Ben-

	Thats just what ruby sees inside itself sort of. If you look at what
that path does though you can see why. the first part ./script is
where you started rails from script/server. then it goes /../config
which means it went up a dir from script and down into config. Then
it does /.. at the end which means it went back up from config into
the root of your rails app. Don't ask why it does all that but it
does end up pointing to the real RAILS_ROOT ;-)

Cheers-
-Ezra Z.
WebMaster
Yakima Herald-Republic Newspaper
removed_email_address@domain.invalid
509-577-7732
Ben M. (Guest)
on 2006-02-20 18:59
(Received via mailing list)
Ezra Z. wrote:
>> But, when I had an action print out RAILS_ROOT it's "./script/../
> Ben-
> -Ezra Z.
Thanks EZ... makes sense... I guess. :-/

b
Kris L. (Guest)
on 2006-02-20 19:38
You can do File.expand_path(RAILS_ROOT) to get a nice path.


Ben M. wrote:
> Ezra Z. wrote:
>>> But, when I had an action print out RAILS_ROOT it's "./script/../
>> Ben-
>> -Ezra Z.
> Thanks EZ... makes sense... I guess. :-/
>
> b
This topic is locked and can not be replied to.