# Invisible attributes?

**URL:** <https://www.ruby-forum.com/t/invisible-attributes/195052>\
**Category:** Rails\
**Created:** [September 15, 2010, 11:01pm UTC](https://www.ruby-forum.com/t/invisible-attributes/195052 "2010-09-15T23:01:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yoram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/e0b2c6/32.png) [@yoram](https://www.ruby-forum.com/u/yoram)\
**Post date:** [September 15, 2010, 11:01pm UTC](https://www.ruby-forum.com/t/invisible-attributes/195052/1 "2010-09-15T23:01:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![yoram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/e0b2c6/32.png) [@yoram](https://www.ruby-forum.com/u/yoram)\
**Post date:** [September 16, 2010, 3:11pm UTC](https://www.ruby-forum.com/t/invisible-attributes/195052/2 "2010-09-16T15:11:22Z")

</div>

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](http://caboo.se/doc/classes/ActiveRecord/MissingAttributeError.html)

Yoram
