I am trying to check if a file exists in my rails application. I am running ruby 1.8.6 and rails 2.1.2 with Windows XP.
So the problem is that FileTest.exists? the method does not seem to work. I simplified the code to this point:
if FileTest.exists?("/images/header.jpg")
render :text => "yes"
else
render :text => "no <img src='/images/header.jpg' />"
end
If I do this, the system will display “no,” and then display an image that displays correctly because /images/header.jpg exists.
I tried FileTest.exists ?, FileTest.exist ?, File.exists ?, File.exist? and nothing works.
What am I doing wrong? Thanks
source
share