Hi all, Just starting with Rails and working through the early chapters of the Pragmatic Programmers Agile Development with Rails book (2nd addition). When doing a "rake db:migrate" to add a column to a table I get this: undefined method `default'' for #<ActiveRecord::ConnectionAdapters::MysqlAdapter:0xb7517ec8> Any ideas? thanks, David PS: Here''s the full output with the trace parameter: dkarnows@star:/share/David/radrails/workspace/depot$ rake db:migrate --trace (in /share/David/radrails/workspace/depot) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate == AddPrice: migrating =======================================================-- default() rake aborted! undefined method `default'' for #<ActiveRecord::ConnectionAdapters::MysqlAdapter:0xb74f240c> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/migration.rb:275:in `send'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/migration.rb:275:in `method_missing'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/migration.rb:259:in `say_with_time'' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/migration.rb:259:in `say_with_time'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/migration.rb:273:in `method_missing'' ./db/migrate//002_add_price.rb:3:in `real_up'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/migration.rb:212:in `migrate'' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/migration.rb:212:in `migrate'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/migration.rb:335:in `migrate'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/migration.rb:330:in `migrate'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/migration.rb:297:in `up'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/migration.rb:288:in `migrate'' /usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/tasks/databases.rake:4 /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 `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 `run'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7 /usr/bin/rake:16 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
David Harkness
2007-Jan-21 06:07 UTC
Re: rake db:migrate "undefined method `default''" error
Could you post the migration code? Common problems include using a reserved word (mysql or ruby. Not sure, but default sounds like a common one. -- 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 -~----------~----~----~----~------~----~------~--~---
That was it, I forgot the colon before the "default": 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 I''m all good now, thanks David, much appreciated. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Fungayi C.
2011-May-25 18:06 UTC
rake aborted! undefined method `task'' for #<Harpers::Application:0x8bd8960> (See full trace by runn
Sorry guys, I am new at RoR and have the above error as I try to run rake db:migrate. Could anyone help. With --trace I get rake db:migrate --trace rake aborted! undefined method `task'' for #<Harpers::Application:0x9277438> /home/student/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks'' /home/student/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks'' /home/student/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'' /home/student/home/harpers/Rakefile:7:in `<top (required)>'' /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load'' /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load_rakefile'' /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:495:in `raw_load_rakefile'' /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:78:in `block in load_rakefile'' /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'' /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:77:in `load_rakefile'' /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:61:in `block in run'' /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'' /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:59:in `run'' /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/bin/rake:31:in `<top (required)>'' /home/student/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in `load'' /home/student/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in `<main>'' -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Александр Лещенко
2011-May-26 12:37 UTC
Re: rake aborted! undefined method `task'' for #<Harpers::Application:0x8bd8960> (See full trace by runn
Just use rake 0.8.7 Uninstall rake 0.9.0 gem uninstall rake -v 0.9.0 And in your Gemfile: gem ''rake'', ''0.8.7'' Don''t forget: bundle install On May 25, 9:06 pm, "Fungayi C." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Sorry guys, I am new at RoR and have the above error as I try to run > rake db:migrate. Could anyone help. > > With --trace I get > > rake db:migrate --trace > rake aborted! > undefined method `task'' for #<Harpers::Application:0x9277438> > /home/student/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:215:in > `initialize_tasks'' > /home/student/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:139:in > `load_tasks'' > /home/student/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:77:in > `method_missing'' > /home/student/home/harpers/Rakefile:7:in `<top (required)>'' > /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in > `load'' > /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in > `load_rakefile'' > /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:495:in > `raw_load_rakefile'' > /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:78:in > `block in load_rakefile'' > /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:129:in > `standard_exception_handling'' > /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:77:in > `load_rakefile'' > /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:61:in > `block in run'' > /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:129:in > `standard_exception_handling'' > /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:59:in > `run'' > /home/student/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/bin/rake:31:in > `<top (required)>'' > /home/student/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in `load'' > /home/student/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in `<main>'' > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Alexander, When I tried that uninstall, I got: While executing gem ... (Gem::InstallError) cannot uninstall, check `gem list -d rake` -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Jul-23 23:37 UTC
Re: rake db:migrate "undefined method `default''" error
On Jul 23, 9:54 pm, "Chris v. N." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Alexander, > > When I tried that uninstall, I got:If you''re using bundler you don''t need to uninstall rake - updating the version required in the gemfile (and running bundle install if you didn''t have 0.8.7 around) should be enough Fred> > While executing gem ... (Gem::InstallError) > cannot uninstall, check `gem list -d rake` > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.