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.
Andrew C. (Guest)
on 2006-01-09 04: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)
Ezra Z. (Guest)
on 2006-01-09 04: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 C. 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
> removed_email_address@domain.invalid

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