If you do end up storing the images in the database, keep in mind that
rail will, by default, use "SELECT * " when retriving the data for an
object. So if you just add a column to your user table that is called
profile_picture, you will be loading whatever is in that column into
memory when you do something like User.find(1). If you store the image
in that column, then you load the image into memory, even if you don’t
need it. You could update your code to specify the select clause–
User.find(1, :select => ‘id, name’), but you would be better off
moving the image into it’s own table. You could create a model called,
ProfilePicture. That model belongs_to :user. User
There are other reasons for not storing images in a database, but I am
probably not the best one to explain the details.
I am using send_file (at http://www.thoughtless.ca) to send images
that require authtication. I have had great performance so far.
However, my images are very small. Almost all of them are less than
100 kb–most are only about 10-20 kb.
send_file should not need to load the whole file into memory (http://
I haven’t tested this myself, but I have generally found that things
committed to rails work as advertised.
I hope that helps,