# Rails\_root

**URL:** <https://www.ruby-forum.com/t/rails-root/70770>\
**Category:** Rails\
**Created:** [February 20, 2006, 8:43am UTC](https://www.ruby-forum.com/t/rails-root/70770 "2006-02-20T08:43:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [February 20, 2006, 8:43am UTC](https://www.ruby-forum.com/t/rails-root/70770/1 "2006-02-20T08:43:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [February 20, 2006, 9:32am UTC](https://www.ruby-forum.com/t/rails-root/70770/2 "2006-02-20T09:32:11Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [February 20, 2006, 5:59pm UTC](https://www.ruby-forum.com/t/rails-root/70770/3 "2006-02-20T17:59:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [February 20, 2006, 6:38pm UTC](https://www.ruby-forum.com/t/rails-root/70770/4 "2006-02-20T18:38:56Z")

</div>

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
