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.
4005a47a8f2ceee49670b920593c1d52?d=identicon&s=25 Ben Munat (Guest)
on 2006-02-20 08: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
8e44c65ac5b896da534ef2440121c953?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-02-20 09:32
(Received via mailing list)
On Feb 19, 2006, at 11:44 PM, Ben Munat wrote:

> does that mean and why isn't RAILS_ROOT the full system path to the
> app?
>
> b
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> 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 Zygmuntowicz
WebMaster
Yakima Herald-Republic Newspaper
ezra@yakima-herald.com
509-577-7732
4005a47a8f2ceee49670b920593c1d52?d=identicon&s=25 Ben Munat (Guest)
on 2006-02-20 17:59
(Received via mailing list)
Ezra Zygmuntowicz wrote:
>> But, when I had an action print out RAILS_ROOT it's "./script/../
> Ben-
> -Ezra Zygmuntowicz
Thanks EZ... makes sense... I guess. :-/

b
3d333b0012928f3dd5a6861cb09ad683?d=identicon&s=25 Kris Leech (Guest)
on 2006-02-20 18:38
You can do File.expand_path(RAILS_ROOT) to get a nice path.


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