我试图运行一个活动记录迁移时,但我收到以下错误:未定义的方法“信息”的零:NilClass运行的活动记录迁移
undefined method 'info' for nil:NilClass
下面是两行代码在我耙运行迁移
ActiveRecord::Base.establish_connection(YAML::load(File.open('src/SupporterSync.Core/Database/Database.yml')))
ActiveRecord::Migrator.migrate('src/SupporterSync.Core/Database/Migrations', ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
这里的任务是我唯一的移民类的文件夹中
class InitialMigration < ActiveRecord::Migration
def self.up
create_table :Accounts, :primary_key => :Id do |t|
t.string :ListId, :limit => 36, :null => false
t.string :Name, :limit => 31, :null => false
t.string :FullName, :limit => 31, :null => false
t.string :ParentListId, :limit => 36
end
end
def self.down
drop_table :Accounts
end
end
这里是跟踪语句:
** Invoke migrate (first_time)
** Execute migrate
rake aborted!
undefined methodinfo' for nil:NilClass<br /> C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/migration.rb :473:in
migrate'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/migration.rb :472:ineach'<br /> C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/migration.rb :472:in
migrate'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/migration.rb :400:inup'<br /> C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/migration.rb :383:in
migrate'
E:/Working/Code/WMF/SupporterSync/rakefile.rb:19
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:incall'<br /> C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:ineach'<br /> C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:ininvoke_with_call_c hain'<br /> C:/Ruby/lib/ruby/1.8/monitor.rb:242:in
synchronize'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_c hain'<br /> C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in
invoke'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task'<br /> C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:ineach'<br /> C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exceptio n_handling'<br /> C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in
top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:inrun'<br /> C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exceptio n_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:inrun'<br /> C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31<br /> C:/Ruby/bin/rake:19:in
load'
C:/Ruby/bin/rake:19
我实际上使用活动记录迁移.net项目,所以这就是为什么命名约定是不同的。 感谢您帮助我解决问题。它一旦我添加日志记录就起作用了。 – Paul 2009-11-13 00:22:31
你认为你可以发布如何定义记录器对象吗? – 2012-04-27 14:47:18