Hi all,
I know this is something probably really simple, but since I’m a noob
I’m
stuck and can’t figure it out. I’m doing the depot project/tutorial in
the
Agile Web D. with Rails. Here’s what happens, while trying to
add
the second migration, adding a missing column, I generate the migration,
002_add_price.rb, then make the changes as outlined in the book:
class AddPrice < ActiveRecord::Migration
def self.up
add_column :products, :price, :decimal, :precision=>8, :scale=>2,
:default=>0
end
def self.down
remove_column :products, :price
end
end
and then run rake db:migrate…which fails.
Here is the --trace
C:\instantrails\work\depot>rake db:migrate --trace
(in C:/instantrails/work/depot)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== AddPrice: migrating
– add_column(:products, :price, :decimal, {:precision=>8, :scale=>2,
:default=>
0})
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.[]
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4
/lib
/active_record/connection_adapters/abstract/schema_statements.rb:259:in
type_to _sql' C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4 /lib /active_record/connection_adapters/abstract/schema_statements.rb:122:in
add_col
umn’
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4
/lib
/active_record/migration.rb:273:in send' C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4 /lib /active_record/migration.rb:273:in
method_missing’
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4
/lib
/active_record/migration.rb:257:in say_with_time' C:/instantrails/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in
measure’
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4
/lib
/active_record/migration.rb:257:in say_with_time' C:/instantrails/InstantRails/ruby/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:3:in real_up' C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4 /lib /active_record/migration.rb:210:in
send’
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4
/lib
/active_record/migration.rb:210:in migrate' C:/instantrails/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in
measure’
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4
/lib
/active_record/migration.rb:210:in migrate' C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4 /lib /active_record/migration.rb:333:in
migrate’
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4
/lib
/active_record/migration.rb:328:in each' C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4 /lib /active_record/migration.rb:328:in
migrate’
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4
/lib
/active_record/migration.rb:295:in up' C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4 /lib /active_record/migration.rb:286:in
migrate’
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6
/lib/tasks/d
atabases.rake:4
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1
/lib/rake.rb:
387:in call' C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1 /lib/rake.rb: 387:in
execute’
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1
/lib/rake.rb:
387:in each' C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1 /lib/rake.rb: 387:in
execute’
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1
/lib/rake.rb:
357:in invoke' C:/instantrails/InstantRails/ruby/lib/ruby/1.8/thread.rb:135:in
synchronize’
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1
/lib/rake.rb:
350:in invoke' C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1 /lib/rake.rb: 1906:in
run’
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1
/lib/rake.rb:
1906:in each' C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1 /lib/rake.rb: 1906:in
run’
C:/instantrails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1
/bin/rake:7
C:/instantrails/InstantRails/ruby/bin/rake.bat:25:in `load’
C:/instantrails/InstantRails/ruby/bin/rake.bat:25
Can anyone tell me what’s happening and how you can decipher that info
from
above…so I can learn to troubleshoot on my own.
Another thing to add is that this did work, and I deleted the project
and
was trying to run through it again.
Thank you in advance for your help,
Greg
–
“Politicians are like diapers, both need to be changed frequently and
for
the same reasons.”
Greg P.
[email protected]