I am a newibie on ruby on the rails. I was following a book example and has the follow exactly code shows on 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 I got the following error message: == 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.[] I have no idea what went wrong. Can anybody help me? Thanks! -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
toby privett
2007-Jan-26 18:51 UTC
Re: I have this error message and don''t know what to do
> 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 > endThis looks fine - and works on my machine. Try running with trace: rake db:migrate --trace --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
jgagne33-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-26 18:59 UTC
Re: I have this error message and don''t know what to do
I just had the exact same problem at apparently the exact same time. Working from the Agile book. Let me know if you figure it out and I''ll do the same. thx J On Jan 26, 12:14 pm, Yan <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I am a newibie on ruby on the rails. I was following a book example and > has the follow exactly code shows on 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 I got the following error message: > == 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.[] > > I have no idea what went wrong. Can anybody help me? > Thanks! > > -- > Posted viahttp://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mick Sharpe
2007-Jan-26 19:42 UTC
Re: I have this error message and don''t know what to do
What version of rake are you using? (do rake --version) -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Here is the trace: (in /home/yan/workspace/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.[] /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:259:in `type_to_sql'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:122:in `add_column'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:273:in `send'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:273:in `method_missing'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:257:in `say_with_time'' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:257:in `say_with_time'' /usr/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'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:210:in `send'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:210:in `migrate'' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:210:in `migrate'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:333:in `migrate'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:328:in `each'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:328:in `migrate'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:295:in `up'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:286:in `migrate'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/tasks/databases.rake:4 /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `call'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `each'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in `invoke'' /usr/lib/ruby/1.8/thread.rb:135:in `synchronize'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `each'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7 /usr/bin/rake:18:in `load'' /usr/bin/rake:18 toby privett wrote:>> 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 > > This looks fine - and works on my machine. > Try running with trace: > > rake db:migrate --trace-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I forgot to mention I am using it on Fedora 6 if it matters. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
rake version 0.7.1 -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dave Thomas
2007-Jan-26 19:55 UTC
Re: I have this error message and don''t know what to do
On Jan 26, 2007, at 12:14 PM, Yan wrote:> > I am a newibie on ruby on the rails. I was following a book example > and > has the follow exactly code shows on the book: > class AddPrice < ActiveRecord::Migration > def self.up > add_column :products, :price, :decimal, :precision => 8, :scale > => 2, > ...> -- 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.[] > > > I have no idea what went wrong. Can anybody help me?Update to Rails 1.2 Dave --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > > Update to Rails 1.2 > > > DaveThanks a lot! It was the problem! Now it working perfectly. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Craig White
2007-Jan-26 21:45 UTC
Re: I have this error message and don''t know what to do
I don''t think rails 1.1.6 supports decimal types but 1.2.1 is supposed to You probably need to upgrade rails and your app Craig On Fri, 2007-01-26 at 20:48 +0100, Yan wrote:> Here is the trace: > > (in /home/yan/workspace/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.[] > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:259:in > `type_to_sql'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:122:in > `add_column'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:273:in > `send'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:273:in > `method_missing'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:257:in > `say_with_time'' > /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:257:in > `say_with_time'' > /usr/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'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:210:in > `send'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:210:in > `migrate'' > /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:210:in > `migrate'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:333:in > `migrate'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:328:in > `each'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:328:in > `migrate'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:295:in > `up'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/migration.rb:286:in > `migrate'' > /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/tasks/databases.rake:4 > /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `call'' > /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'' > /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `each'' > /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'' > /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in `invoke'' > /usr/lib/ruby/1.8/thread.rb:135:in `synchronize'' > /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke'' > /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'' > /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `each'' > /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'' > /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7 > /usr/bin/rake:18:in `load'' > /usr/bin/rake:18 > > > > > > > > > > > > > > > > toby privett wrote: > >> 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 > > > > This looks fine - and works on my machine. > > Try running with trace: > > > > rake db:migrate --trace > >-- Craig White <craig-CnJ8jr4MGtxl57MIdRCFDg@public.gmane.org> --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---