Forum: Ruby on Rails attachment_fu and mysql (server has gone away)

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Luca R. (Guest)
on 2008-12-29 20:03
I have a problem with my hosting "hostgator"

In my site i have a section for photos upload.
For manage it i use attachment_fu.
In the action of upload i do some simple query.

If the file to upload is smaller than 1mb there isnt any problem

but if it is bigger than 1 mb about i receive an error:

mysql error server has gone away.

i wrote to hostgator. they responsed me with:

All MySQL connections open for more than 15 seconds are killed off once
a minute.  Your script needs to be modified so the MySQL connection is
opened just prior to the query actually being run

How i can to open mysql connection only when i do query for this action?
This topic is locked and can not be replied to.