# Migration Bug?

**URL:** <https://www.ruby-forum.com/t/migration-bug/121658>\
**Category:** Rails\
**Created:** [November 29, 2007, 6:10pm UTC](https://www.ruby-forum.com/t/migration-bug/121658 "2007-11-29T18:10:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sp00nyg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@sp00nyg](https://www.ruby-forum.com/u/sp00nyg)\
**Post date:** [November 29, 2007, 6:10pm UTC](https://www.ruby-forum.com/t/migration-bug/121658/1 "2007-11-29T18:10:18Z")

</div>

Please tell me I’m just confused, but this is very strange.

I have a migration like so:

class AddLevelToRequest \< ActiveRecord::Migration  
def self.up  
add\_column :requests, :title\_levels, :string  
end  
def self.down  
remove\_column :requests, :title\_levels  
end  
end

Run the migration, and from the console do:

> > r = Request.new  
> > =\> #\<Request:0x31a243c @attributes={“title\_levels”=\>nil,  
> > “department”=\>nil, …

So far so good. My new attribute is there. Now do:

> > r = Request.new(:title\_levels =\> “1,2,3”)  
> > =\> #\<Request:0x30d3524 @attributes={“title\_levels”=\>nil,  
> > “department”=\>nil, …

What happened? Where did my attribute value go? If I do:

> > r = Request.new(:department =\> “1,2,3”)  
> > =\> #\<Request:0x30c7698 @attributes={“title\_levels”=\>nil,  
> > “department”=\>“1,2,3”, …

The department attribute was created with the table.

I can do the following:

> > r.title\_levels = “1,2,3”  
> > =\> “1,2,3”
> 
> > r  
> > =\> #\<Request:0x30c7698 @attributes={“title\_levels”=\>“1,2,3”, …

Is something broken with add\_column? I tried several different forms,  
but it seems that no matter what I do I can’t get new columns to work  
with new. I also tried adding more columns, but all columns added with  
add\_column exhibited the same behavior.

I first noticed this when I tried to submit a form, but @request =  
Request.new(params[:request]) was not picking up the title\_levels  
field.

I’m using Ruby 1.8.6, Rails 1.2.6, and MySql 5.0.41 on Max OS 10.4.

---

<div class="post-metadata">

**Author:** ![sp00nyg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@sp00nyg](https://www.ruby-forum.com/u/sp00nyg)\
**Post date:** [November 29, 2007, 8:34pm UTC](https://www.ruby-forum.com/t/migration-bug/121658/2 "2007-11-29T20:34:12Z")

</div>

Whew! I was just confused. I forgot I had a attr\_accessible setup  
for the Request class. Once I added title\_levels to that, everything  
worked fine.

Now, it’s time to go bang my head against the wall…
