Forum: Ruby on Rails Migration Issue

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
94cc3e46cfc5bc361e409e2e884ecfa4?d=identicon&s=25 Drew Olson (dfg59)
on 2006-12-27 04:22
I'm following along with the example in Agile, and I'm simply trying to
create a migration to add a price column to a table called products.
This table exists as my application is displaying it using a scaffold.
Here's my migration:

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

However when I run my migration I get the following:

powerbook-g4-15:~/Documents/work/depot drew$ rake db:migrate
(in /Users/drew/Documents/work/depot)
== AddPrice: migrating
========================================================
-- add_column(:products, :price, :decimal, {:precision=>8, :default=>0,
: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.[]

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

Any help would be great... I feel like a moron, I'm sure I've gotten
this working before, just trying to follow along with the example in the
book.
8984c514dc77aaf6b04fc4fd8359584c?d=identicon&s=25 boboroshi (Guest)
on 2006-12-27 05:03
(Received via mailing list)
You need to update to Rails 1.2 RC 1. Since the book relies on edge,
that's where you can fix your issue.

gem install rails --source http://gems.rubyonrails.org
--include-dependencies

is the code to run

For more info:
http://weblog.rubyonrails.org/2006/11/23/rails-1-2...
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (Guest)
on 2006-12-27 05:05
(Received via mailing list)
Hi, could you post your migration file?

-Conrad
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (Guest)
on 2006-12-27 05:07
(Received via mailing list)
Hi, I see it.

-C
94cc3e46cfc5bc361e409e2e884ecfa4?d=identicon&s=25 Drew Olson (dfg59)
on 2006-12-27 05:19
boboroshi wrote:
> You need to update to Rails 1.2 RC 1. Since the book relies on edge,
> that's where you can fix your issue.
>
> gem install rails --source http://gems.rubyonrails.org
> --include-dependencies
>
> is the code to run
>
> For more info:
> http://weblog.rubyonrails.org/2006/11/23/rails-1-2...

I am running this from inside locomotive, so I attempted to update my
rails install inside locomotive by doing the following:

gem update rails --source http://gems.rubyonrails.org
--include-dependencies

However, now when I do rails -v, I see:

powerbook-g4-15:~/Documents/work/depot drew$ rails -v
Rails 1.1.6

Still getting the same error as well...
8984c514dc77aaf6b04fc4fd8359584c?d=identicon&s=25 boboroshi (Guest)
on 2006-12-27 05:31
(Received via mailing list)
Drew, Agile v2 requires edge/1.2. I don't think there's any way around
it. I would reccomend following Dan Benjamin's phenomenal step by step
directions here:

http://hivelogic.com/articles/2005/12/01/ruby_rail...

and run it that way. It will return as 1.1.6 from shell, but do a gem
list to verify you're on edge.

soho:~ jathayde$ rails -v
Rails 1.1.6


and you'll see "1.1.6.5618" as the version number.

soho:~ jathayde$ gem list

*** LOCAL GEMS ***

actionmailer (1.2.5.5618, 1.2.5)
    Service layer for easy email delivery and testing.

actionpack (1.12.5.5618, 1.12.5)
    Web-flow and rendering framework putting the VC in MVC.

actionwebservice (1.1.6.5618, 1.1.6)
    Web service support for Action Pack.

activerecord (1.14.4.5618, 1.14.4)
    Implements the ActiveRecord pattern for ORM.

activesupport (1.3.1.5618, 1.3.1)
    Support and utility classes used by the Rails framework.

rails (1.1.6.5618, 1.1.6)
    Web-application framework with template engine, control-flow layer,
    and ORM.

EnjoY!
94cc3e46cfc5bc361e409e2e884ecfa4?d=identicon&s=25 Drew Olson (dfg59)
on 2006-12-27 05:33
boboroshi wrote:
> Drew, Agile v2 requires edge/1.2. I don't think there's any way around
> it. I would reccomend following Dan Benjamin's phenomenal step by step
> directions here:

Bob -

Thanks for the help thus far. I do indeed now have Raisl edge/1.2
installed. However I am receiving the very same error I first discussed.
Here's my full trace:

drew-olsons-powerbook-g4-15:~/Documents/work/depot drew$ rake db:migrate
--trace
(in /Users/drew/Documents/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, :default=>0,
: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.[]
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/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/rmagickRailsSept2006_ppc.locobundle/framework/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/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:273:in
`method_missing'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:257:in
`say_with_time'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/1.8/benchmark.rb:293:in
`measure'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:257:in
`say_with_time'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/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/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:210:in
`migrate'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/1.8/benchmark.rb:293:in
`measure'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:210:in
`migrate'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:333:in
`migrate'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:328:in
`migrate'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:295:in
`up'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:286:in
`migrate'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/tasks/databases.rake:4
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in
`execute'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in
`execute'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in
`invoke'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/1.8/thread.rb:135:in
`synchronize'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in
`invoke'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in
`run'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in
`run'
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7
/Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/bin/rake:18
drew-olsons-powerbook-g4-15:~/Documents/work/depot drew$
This topic is locked and can not be replied to.