Rails_root


#1

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


#2

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 :wink:

Cheers-
-Ezra Z.
WebMaster
Yakima Herald-Republic Newspaper
removed_email_address@domain.invalid
509-577-7732


#3

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


#4

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