Welcome Guest | Login

path to read a file

I have a file that my application needs to read. I am able to read it on localhost, but I can't seem to get the path working on the deployed machine. The file is in ssl/private and called omr_keys.pem The ssl folder is at the same level as my rails-application root folder - the one that holds app and public, etc.

In my app, I make this call
f = File.new(File.join(RAILS_ROOT, 'ssl', 'private', 'omr_keys.pem'))

Works fine in my localhost , however, on my deployed application I get
Errno::ENOENT (No such file or directory - ./../config/../ssl/private/omr_keys.pem):

What is the correct path to this file ?

2008-07-29 09:48 AM

Hi Tracey,

Please make sure that the file omr_keys.pem is on the location ./../config/../ssl/private. It seems like the file is not existing in the location /../config/../ssl/private.

2008-07-29 10:50 AM

Thanks for the response. I am pretty sure I had the file in the right place. However, rather than struggle, I put the file in my config folder. Then I can access it with f = File.new(File.join(RAILS_ROOT, 'config', 'omr_keys.pem'))

However, I have a new problem now. Apparently, when I read the file, as in key = f.read - the contents of the file is also read to standard out. This is OK on my development machine, but causes a big problem on the deployed application - just like having a puts statement lurking in the code. How can I read the file "silently" - without any output ??

2008-07-29 11:41 AM

Hi Tracey,

Are you getting any errors while browsing, after placing the 'omr_keys.pem' file in the config folder ?  

2008-07-29 01:34 PM

Thanks again for the reply. Sorry if it takes a few iterations to describe the issue. I don't have any trouble browsing to the application or using it. I have one particular action within which the controller has to read information in a file. (There may be better ways to do this, but this is simple for now) When the web page asks for that action, I get the blank white Application error - Rails application failed to start properly page. Nothing shows up in the production log. However, I have seen similar behavior in the past. So, careful review of the code, and observing how it behaves in my localhost IDE makes me see that the file read step is causing the problem. If I comment that out, the error does not occur (of course, the application doesn't function)

So - I think I need to read that file quietly, without sending anything to the console, or standard out.

2008-07-29 04:20 PM

Hi there - if you use readlines (instead of read) and join the resulting array does the same problem happen?  

2008-07-29 07:45 PM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!