Path problem after deployment

I have my first RoR app deployed on a hosting server using CGI: making
a simlink in ~/public_html to the “public” directory of my rails app.

Everything works fine except that the app can only read/write any file
‘RAILS_ROOT/public’ directory. For example, on my development machine
I use ‘public/images/filename.jpg’ to access image files, but on the
hosting server I get errors like “unable to open image ‘public/images/
filename.jpg’: No such file or directory”. The file actually exists
but the app seems to be navigating the relative path from ‘RAILS_ROOT/
public’ instead of RAILS_ROOT. I can change the path string in my code
so that the app can run correctly on the hosting server, but that way
I won’t be able to run it on my development computer.

This directoy access problem only happens in .rb files, for example
uploading a picture and saving it to ‘public/images’. In rthml files
everyting is just fine.

Does this have anyting to do with the setting of RAILS_ROOT?

Thanks
Yi