dkarnows
(dkarnows)
January 21, 2007, 6:04am
1
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
dkarnows
(dkarnows)
January 21, 2007, 6:10am
2
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.
11155
(-- --)
May 25, 2011, 6:06pm
3
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>'
11152
(Александр Лещенко)
May 26, 2011, 12:37pm
4
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
11155
(-- --)
July 23, 2011, 8:54pm
5
Alexander,
When I tried that uninstall, I got:
While executing gem ... (Gem::InstallError)
cannot uninstall, check `gem list -d rake`
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