# IO.read fails on relative path in model object

**URL:** <https://www.ruby-forum.com/t/io-read-fails-on-relative-path-in-model-object/57647>\
**Category:** Rails\
**Created:** [April 12, 2006, 8:11pm UTC](https://www.ruby-forum.com/t/io-read-fails-on-relative-path-in-model-object/57647 "2006-04-12T20:11:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 12, 2006, 8:11pm UTC](https://www.ruby-forum.com/t/io-read-fails-on-relative-path-in-model-object/57647/1 "2006-04-12T20:11:18Z")

</div>

All,

I am attempting to do an IO.read call on a file inside of one of my  
model objects.

I keep getting Errno::ENOENT

The path I’m passing to IO.read is relative to RAILS\_ROOT.

Two questions:

1. This code was previously executing in my controller - it it  
significant that I moved it into my model?

2. Is there some way to verify which directory is the current directory  
for the app.?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 12, 2006, 8:13pm UTC](https://www.ruby-forum.com/t/io-read-fails-on-relative-path-in-model-object/57647/2 "2006-04-12T20:13:57Z")

</div>

I just verified that I can run this same call in my controller object  
without a problem.

Wes G. wrote:

> All,
> 
> I am attempting to do an IO.read call on a file inside of one of my  
> model objects.
> 
> I keep getting Errno::ENOENT
> 
> The path I’m passing to IO.read is relative to RAILS\_ROOT.
> 
> Two questions:
> 
> 1. This code was previously executing in my controller - it it  
> significant that I moved it into my model?
> 
> 2. Is there some way to verify which directory is the current directory  
> for the app.?
> 
> Thanks,  
> Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 12, 2006, 8:34pm UTC](https://www.ruby-forum.com/t/io-read-fails-on-relative-path-in-model-object/57647/3 "2006-04-12T20:34:20Z")

</div>

Sorry guys.

Was in the wrong directory. I chdir’ed and never chdir’ed back to where  
I thought I was.

Wes G. wrote:

> I just verified that I can run this same call in my controller object  
> without a problem.
> 
> Wes G. wrote:
> 
> > All,
> > 
> > I am attempting to do an IO.read call on a file inside of one of my  
> > model objects.
> > 
> > I keep getting Errno::ENOENT
> > 
> > The path I’m passing to IO.read is relative to RAILS\_ROOT.
> > 
> > Two questions:
> > 
> > 1. This code was previously executing in my controller - it it  
> > significant that I moved it into my model?
> > 
> > 2. Is there some way to verify which directory is the current directory  
> > for the app.?
> > 
> > Thanks,  
> > Wes
