Rob Biedenharn wrote:
> 
> Did you actually run:  rake --trace db:migrate
> so you can see where the problem happens?

I did, but the trace information is meaningless to me.  I'll paste it in 
below.

> That's the first thing to do.  Since the OP's error happened over 2
> years ago (!), you might as well consider your error "new" and post
> the details.  Anyone who generally follows via the mailing list isn't
> even going to know what the OP context is (unless they go looking like
> I had to.)

Good point.  I'm accessing this through a web forum (found the original 
post through google) and didn't realize there was as associated mailing 
list (though now I see that it says so at the bottom of the page).

As noted, I'm working from the paper version of the AWDwR book.  I'm 
using Locomotive2 (2.0.8) as my Ruby/Rails install on MacOS.

In section 6.2 of the book where the second migration is created, I ran 
into the following error:

% rake db:migrate
(in /Users/mattp/devel/ruby/depot)
== AddPrice: migrating 
========================================================
-- add_column(:products, :price, :decimal, {:scale=>2, :default=>0, 
:precision=>8})
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.[]

(See full trace by running task with --trace)

After finding this thread with the note about rake 1.1.6 vs 1.2 
compatibility of the book's instructions, I upgraded rake:

% which gem
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/bin//gem

% sudo gem install rails --version 1.2
Bulk updating Gem source index for: http://gems.rubyforge.org
Install required dependency activesupport? [Yn]
Install required dependency activerecord? [Yn]
Install required dependency actionpack? [Yn]
Install required dependency actionmailer? [Yn]
Install required dependency actionwebservice? [Yn]
Successfully installed rails-1.2.0
Successfully installed activesupport-1.4.0
Successfully installed activerecord-1.15.0
Successfully installed actionpack-1.13.0
Successfully installed actionmailer-1.3.0
Successfully installed actionwebservice-1.2.0
Installing ri documentation for activesupport-1.4.0...

lib/active_support/dependencies.rb:52:16: Unrecognized directive 'nodoc'
Installing ri documentation for activerecord-1.15.0...
Installing ri documentation for actionpack-1.13.0...

lib/action_controller/routing.rb:1050:30: ':' not followed by identified 
or operator

lib/action_controller/routing.rb:1054:39: ':' not followed by identified 
or operator
Installing ri documentation for actionmailer-1.3.0...
Installing ri documentation for actionwebservice-1.2.0...
Installing RDoc documentation for activesupport-1.4.0...

lib/active_support/dependencies.rb:52:16: Unrecognized directive 'nodoc'
Installing RDoc documentation for activerecord-1.15.0...
Installing RDoc documentation for actionpack-1.13.0...

lib/action_controller/routing.rb:1050:30: ':' not followed by identified 
or operator

lib/action_controller/routing.rb:1054:39: ':' not followed by identified 
or operator
Installing RDoc documentation for actionmailer-1.3.0...
Installing RDoc documentation for actionwebservice-1.2.0...


% rails --version
Rails 1.2.0

However, after that upgrade I'm still seeing the same error from rake 
when I try the db migration.

Doing the migrate with --trace now gives this output (sorry, I don't 
have the output prior to my rails update)

% rake db:migrate --trace
(in /Users/mattp/devel/ruby/depot)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== AddPrice: migrating 
========================================================
-- add_column(:products, :price, :decimal, {:scale=>2, :default=>0, 
:precision=>8})
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.[]
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:259:in
 
`type_to_sql'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:122:in
 
`add_column'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:273:in
 
`method_missing'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:257:in
 
`say_with_time'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/1.8/benchmark.rb:293:in
 
`measure'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:257:in
 
`say_with_time'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/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'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:210:in
 
`migrate'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/1.8/benchmark.rb:293:in
 
`measure'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:210:in
 
`migrate'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:333:in
 
`migrate'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:328:in
 
`migrate'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:295:in
 
`up'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:286:in
 
`migrate'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/tasks/databases.rake:4
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in
 
`execute'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in
 
`execute'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in
 
`invoke'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/1.8/thread.rb:135:in
 
`synchronize'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in
 
`invoke'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in
 
`run'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in
 
`run'
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/bin//rake:18


In case of some typo that I'm not spotting (I've double and triple 
checked, but that doesn't necessarily mean I've caught everything) I'm 
also going to paste the new migration that I'm trying to run:

% cat db/migrate/002_add_price.rb
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

Thanks for any help!
   Matt
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to