Invisible attributes?

I recently tried to pull a database from our server and load it into my
local MySQL. I got the dreaded ‘MySQL server has gone away’. Digging a
little deeper, I found that it choked on the first User record. We
recently added several attributes of type ‘binary’ to the User object. I
suspected an issue around these. When I started poking around in my
local db, through the ruby console, I found the following very strange
behaviour (certain irrelevant fields x’d out to protect the innocent):

me = User.find(8)
=> #<User id: 8, account_id: 1, login: “xxxxx”, email:
“xxxxxxxxxxxxxxx”, name: “xxxxx xxxxxx”, admin: false, remember_token:
“b7f1baad18daf19a5d52e9935bf23430e0f91e38”, crypted_password:
“02a5da32749bd5478fee2b094e4857728a2fbfc0”, salt: “-6151795480.1557195
22328172”, remember_token_expires_at: “2010-09-28 18:33:39”,
terms_of_use_accepted: “2010-06-19 15:12:27”, reminder_emails: true, sa
lon_id: 4, community_id: 1, updated_at: “2010-09-14 11:33:39”,
created_at: “2010-04-01 21:29:22”, public_name: “Yoram”, salon_name:
“Yoram”, broadcast_message_read: “1969-12-31 16:00:00”, community_name:
“Yoram”, newsletter: true, avatar_updated_at: “2010-09-06 14
:16:20”, avatar_file_size: 51473, avatar_file_name: “me.jpg”,
avatar_content_type: “image/jpeg”>

me.avatar_file
ActiveRecord::MissingAttributeError: missing attribute: avatar_file

foo = User.new
=> #<User id: nil, account_id: nil, login: nil, email: nil, name: nil,
admin: false, remember_token: nil, crypted_password: nil, sal
t: nil, remember_token_expires_at: nil, terms_of_use_accepted: nil,
reminder_emails: nil, salon_id: nil, community_id: nil, updated_
at: nil, created_at: nil, public_name: nil, salon_name: nil,
broadcast_message_read: “1969-12-31 16:00:00”, community_name: nil, new
sletter: nil, avatar_thumb_file: nil, avatar_medium_file: nil,
avatar_updated_at: nil, avatar_file_size: nil, avatar_file_name: nil,
avatar_file: nil, avatar_icon_file: nil, avatar_content_type: nil>

foo.avatar_file
=> nil

Note that, for the already existing user object, i’m told that the
avatar_file attribute does not exist. On th eother hand, for a newly
created object, it exsits. All my migrations have been run and are up to
date. My local MySQL browser does see the attribute and its contents.

What’s going on here? The attribute is of type binary… Thanks for any
advice.

I was able to resolve this - in order to pull the db, I had to
increasemax_allowed_packet on MySQL

The weirdness on the invisible attribute was because of the way the
SELECT works:
http://caboo.se/doc/classes/ActiveRecord/MissingAttributeError.html

Yoram