As the other contributors to this thread have said, it is most likely that mysql server has closed the connection to your rails app because of inactivity. The default timeout is 28800 seconds, or 8 hours.
set-variable = wait_timeout=86400
Adding this line to your /etc/my.cnf will raise the timeout to 24 hours
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#option_mysqld_wait_timeout
Although the documentation doesn't indicate it, a value of 0 may disable the timeout completely, but you would need to experiment as this is just speculation.
There are however three other situations that I know of that can generate that error. The first is the mysql server being restarted. This will obviously drop all the connections, but as the mysql client is passive, this won't be noticed till you do the next query.
The second condition is if someone kills your query from the mysql command line, this also drops the connection because it could leave the client in an undefined state.
The last is if your mysql server restarts itself due to a fatal internal error. That is, if you are doing a simple query against a table and instantly see 'mysql has gone away', I'd take a close look at your server's logs to check for hardware error, or database corruption.