[ACCEPTED]-FileTest.exists? issue with ruby on rails-file
Accepted answer
I'm guessing it's because you're asking 7 whether a file "header.jpg" exists in a 6 directory "images" off of the root directory 5 for your system (which on Windows I'd assume 4 is "c:\"). Try putting the full path (from 3 the filesystem root) to the "/images" directory 2 rather than the URL path.
In particular, as 1 pointed out by @Brian, you should use:
FileTest.exists?(RAILS_ROOT + "/images/header.jpg") # < rails 3.0
FileTest.exists?(Rails.root + "/images/header.jpg") # >= rails 3.0
Add RAILS_ROOT
to the filename that you're checking 1 before calling exists?
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.