Forum: Ruby on Rails IO.read fails on relative path in model object

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.
Wes G. (Guest)
on 2006-04-12 22:11
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
Wes G. (Guest)
on 2006-04-12 22:13
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
Wes G. (Guest)
on 2006-04-12 22:34
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
This topic is locked and can not be replied to.