Reading a file using File.read

Hi,

File.read(VALID_PATH_TO_FILE) works on ruby console but not as a rails application. I dont understand why it fails saying "No such file or directory". Even File.exist? returns false from rails application output but returns true from rails console. It has readable permissions for the current user , so that's not an issue. What might be the cause of this problem?

Are you using a relative path? You might just be in a different working directory in your Rails app.

Im using absolute path. Actually i mounted a directory from remote server and do a "find" for a specific file and then try reading it. The cmd find passes and returns a valid path to the file. But only the read cmd fails.

I think i understood the problem