Recently I was porting a legacy PHP application to Rails. One of the primary tasks was to resize a bunch of images. Below you can see what one of the database rows looks like.
You’ll see that the name of the filename is stored in the database, the problem I encountered was that often times the actual file didn’t exist even though the record remained in the database.
Rails would get angry at me when I tried to resize an non-existent file. To account for this, I did the following:
if FileTest.exists?(filename)
# some code here to
# resize the image
end
# some code here to
# resize the image
end
For more information on this handy ruby module pop into the docs.
I bet I should use this like <div class=”clear”></div>. All over the place!
thanks a lot.. i had written a function to do the same thing…but when you so beautifully described it in a line.. take care.. cheers !
hmmm its usefull info of ruby on rails