Forum: Ruby on Rails Question about image storage and relative paths

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
2c9c63e72bc96de12e6acd7ba07d6f02?d=identicon&s=25 Andrew Chen (Guest)
on 2006-01-09 03:10
(Received via mailing list)
I'm writing a website with a feature that hosts images that people

Right now, relative paths works within on my Windows box. So
specifically, I'm able to call on
"public/images/somefile.jpg" and Rails/WEBrick understands that the
path is relative to the home directory of the project. This means that
"public/images/somefile.jpg" ends up referring to the absolute path

The problem is now I've pushed this out to a Linux box running
Lighty/FastCGI and I get the error Errno::ENOENT with message:

"No such file or directory - public/images/somefile.jpg"

I found that if I prepend the public with the actual path - so,
/usr/local/rails/SomeProject/current/public/images/somefile.jpg" then
the entire setup works.

Any ideas on the best way to approach this?

In particular, a couple ways to fix this:
- Is there a method that returns the home directory of the app?
- Is there a method which complements image_path and tells me the file
system location of where a file should be saved?
- Is there a switch to force Rails to understand relative paths?

Let me know if you guys have any ideas.

Thanks in advance!

(from Seattle, WA)
8e44c65ac5b896da534ef2440121c953?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-01-09 03:52
(Received via mailing list)

	The constant  RAILS_ROOT always refers to your rails apps root dir.
So just make your paths like this:



On Jan 8, 2006, at 6:09 PM, Andrew Chen wrote:

> The problem is now I've pushed this out to a Linux box running
> In particular, a couple ways to fix this:
> (from Seattle, WA)
> _______________________________________________
> Rails mailing list

-Ezra Zygmuntowicz
Yakima Herald-Republic Newspaper
This topic is locked and can not be replied to.