# SerializationTypeMismatch in Production Mode

**URL:** <https://www.ruby-forum.com/t/serializationtypemismatch-in-production-mode/86007>\
**Category:** Rails\
**Created:** [February 18, 2007, 11:12pm UTC](https://www.ruby-forum.com/t/serializationtypemismatch-in-production-mode/86007 "2007-02-18T23:12:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 18, 2007, 11:12pm UTC](https://www.ruby-forum.com/t/serializationtypemismatch-in-production-mode/86007/1 "2007-02-18T23:12:21Z")

</div>

In production mode, I keep getting this error the 2nd time it loads a  
page with a serialized attribute:

ActiveRecord::SerializationTypeMismatch (answers\_container was  
supposed to be a Array, but was a NilClass):  
/vendor/rails/activerecord/lib/active\_record/base.rb:1964:in  
`unserialize\_attribute’

In development, it works fine. In fact, if I set to false  
config.cache\_classes in production.rb, it works fine.

The first time you hit the page, it works fine. Upon refresh, it  
returns that error.

This happens with both webbrick and litespeed.

The controller code is:

def new  
store\_location  
if request.env[“HTTP\_REFERER”]  
params[:my\_id] = “survey” if  
request.env[“HTTP\_REFERER”].include? “survey”  
end  
@question = Question.new  
@question.answers\_container = Array.new(2, “”)  
@question.creator\_message = current\_user[:note] if logged\_in?  
end

In my model, I define the serialized attribute as such:  
serialize :answers\_container, Array

I was running rails 1.2, then upgraded to 1.2.2 after seeing I have  
this problem. I believe when I was running 1.1.6 I did not have this  
problem.

Does anyone have any suggestions?

Steve

> **[Niblets....Simple. Less.](https://niblets.wordpress.com/)**
>
> Just another WordPress.com weblog

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 19, 2007, 1:59am UTC](https://www.ruby-forum.com/t/serializationtypemismatch-in-production-mode/86007/2 "2007-02-19T01:59:35Z")

</div>

What databases are you using (mysql? postgres?, …) ? Are they  
different in development and production?

-carl

On 2/18/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> config.cache\_classes in production.rb, it works fine.  
> if request.env[“HTTP\_REFERER”]
> 
> >

–  
EPA Rating: 3000 Lines of Code / Gallon (of coffee)

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 19, 2007, 2:17am UTC](https://www.ruby-forum.com/t/serializationtypemismatch-in-production-mode/86007/3 "2007-02-19T02:17:36Z")

</div>

Both mysql. Everything is the same. In fact, on my local machine, both  
production and development databases use the same mysql database.
