# Rake db:migrate problem

**URL:** <https://www.ruby-forum.com/t/rake-db-migrate-problem/76179>\
**Category:** Rails\
**Created:** [November 16, 2006, 3:07pm UTC](https://www.ruby-forum.com/t/rake-db-migrate-problem/76179 "2006-11-16T15:07:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [November 16, 2006, 3:07pm UTC](https://www.ruby-forum.com/t/rake-db-migrate-problem/76179/1 "2006-11-16T15:07:57Z")

</div>

I am just starting out learning RoR. I am trying to follow along with  
the Depot project in “Agile Web D. With Rails ed2” and get the  
error “You have a nil object when you didn’t expect it! You might have  
expected an instance of Array. The error occured while evaluating  
nil.[]” I ran --trace and get the following, but I am not sure what it  
means. Can anyone help me make sense out of it? Thanks

Mike R.

# (in /Users/mike/work/depot) \*\* Invoke db:migrate (first\_time) \*\* Invoke environment (first\_time) \*\* Execute environment \*\* Execute db:migrate == AddPrice: migrating

– add\_column(:products, :price, :decimal, {:default=\>0, :precision=\>8,  
:scale=\>2})  
rake aborted!  
You have a nil object when you didn’t expect it!  
You might have expected an instance of Array.  
The error occured while evaluating nil.[]  
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/connection\_adapters/abstract/schema\_statements.rb:259:in  
`type_to_sql' /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:122:in`add\_column’  
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/migration.rb:273:in  
`send' /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:273:in`method\_missing’  
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/migration.rb:257:in  
`say_with_time' /opt/local/lib/ruby/1.8/benchmark.rb:293:in`measure’  
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/migration.rb:257:in  
`say_with_time' /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:271:in`method\_missing’  
./db/migrate//002\_add\_price.rb:8:in `real_up' /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:210:in`send’  
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/migration.rb:210:in  
`migrate' /opt/local/lib/ruby/1.8/benchmark.rb:293:in`measure’  
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/migration.rb:210:in  
`migrate' /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:333:in`migrate’  
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/migration.rb:328:in  
`each' /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:328:in`migrate’  
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/migration.rb:295:in  
`up' /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:286:in`migrate’  
/opt/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/tasks/databases.rake:4  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `call' /opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in`execute’  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `each' /opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in`execute’  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in `invoke' /opt/local/lib/ruby/1.8/thread.rb:135:in`synchronize’  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke' /opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in`run’  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `each' /opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in`run’  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7  
/opt/local/bin/rake:18:in `load’  
/opt/local/bin/rake:18

---

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [November 16, 2006, 3:35pm UTC](https://www.ruby-forum.com/t/rake-db-migrate-problem/76179/2 "2006-11-16T15:35:58Z")

</div>

On 11/16/06, Mike R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am just starting out learning RoR. I am trying to follow along with  
> the Depot project in “Agile Web D. With Rails ed2” and get the  
> error “You have a nil object when you didn’t expect it! You might have  
> expected an instance of Array. The error occured while evaluating  
> nil.[]” I ran --trace and get the following, but I am not sure what it  
> means. Can anyone help me make sense out of it? Thanks

You need to upgrade your rails version for this example to work. The  
decimal type isn’t supported by the current stable release.

I’m sure this procedure is described somewhere close to the example.

HTH,  
Isak

---

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [November 16, 2006, 3:50pm UTC](https://www.ruby-forum.com/t/rake-db-migrate-problem/76179/3 "2006-11-16T15:50:07Z")

</div>

On Thu, 2006-11-16 at 15:07 +0100, Mike R. wrote:

> # \*\* Invoke db:migrate (first\_time) \*\* Invoke environment (first\_time) \*\* Execute environment \*\* Execute db:migrate == AddPrice: migrating
> 
> – add\_column(:products, :price, :decimal, {:default=\>0, :precision=\>8,  
> :scale=\>2})  
> rake aborted!  
> You have a nil object when you didn’t expect it!

* * *

My understanding of AWDWR ed 2 is that it requires Rails 1.2 which isn’t  
available yet in any form other than ‘edge rails’ which by default,  
isn’t what gets installed.

I hesitated to reply because I am uncertain of the incantation required  
to get edge rails installed and functional

Craig

---

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [November 16, 2006, 4:00pm UTC](https://www.ruby-forum.com/t/rake-db-migrate-problem/76179/4 "2006-11-16T16:00:13Z")

</div>

On Nov 16, 2006, at 7:07 AM, Mike R. wrote:

> I am just starting out learning RoR. I am trying to follow along with  
> the Depot project in “Agile Web D. With Rails ed2” and get  
> the  
> error “You have a nil object when you didn’t expect it! You might have  
> expected an instance of Array. The error occured while evaluating  
> nil.[]” I ran --trace and get the following, but I am not sure  
> what it  
> means. Can anyone help me make sense out of it? Thanks

The book is written for Rails 1.2, but there seem to be some problems  
getting that released. In the meantime, I prepared a temporary  
release that helps you install Edge Rails in your application. If yo  
look at the second page of the PDF (the one after the cover page)  
you’ll find an explanation and instructions.

Regards

Dave T.

---

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [November 16, 2006, 4:08pm UTC](https://www.ruby-forum.com/t/rake-db-migrate-problem/76179/5 "2006-11-16T16:08:10Z")

</div>

Dave T. wrote:

> The book is written for Rails 1.2, but there seem to be some problems  
> getting that released. In the meantime, I prepared a temporary  
> release that helps you install Edge Rails in your application. If yo  
> look at the second page of the PDF (the one after the cover page)  
> you’ll find an explanation and instructions.
> 
> Regards
> 
> Dave T.

Thanks Dave,

I ran the rake rails:update as shown on the second page, but never  
checked to see if it actually work. Looks like the problem was it  
didn’t. I did get the update to take by rails:freeze:edge and now the  
database updates. It is a great book so far.

Thanks  
Mike R.
