rake db:migrate(+ desert)给出了“未定义的方法`abstract_class?” for Object:Class“

时间:2010-09-21 11:15:01

标签: ruby-on-rails ruby-on-rails-plugins

我只是尝试运行迁移,但是我得到了以下的堆栈跟踪(下面)。

我正在使用rails 2.3.8并且使用0.5.4。

rake aborted!
undefined method `abstract_class?' for Object:Class
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2242:in `class_of_active_record_descendant'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:1492:in `base_class'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:1164:in `reset_table_name'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:1160:in `table_name'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:3154:in `quoted_table_name'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2261:in `sanitize_sql'
/usr/lib/ruby/gems/1.8/gems/desert-0.5.4/lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:24:in `send'
/usr/lib/ruby/gems/1.8/gems/desert-0.5.4/lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:24:in `initialize_schema_migrations_table'
/usr/lib/ruby/gems/1.8/gems/desert-0.5.4/lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:23:in `each'
/usr/lib/ruby/gems/1.8/gems/desert-0.5.4/lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:23:in `initialize_schema_migrations_table'
/usr/lib/ruby/gems/1.8/gems/desert-0.5.4/lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:12:in `each'
/usr/lib/ruby/gems/1.8/gems/desert-0.5.4/lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:12:in `initialize_schema_migrations_table'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:441:in `initialize'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:401:in `new'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:401:in `up'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:383:in `migrate'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/tasks/databases.rake:112
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

这个小虫似乎出现在以下一行的沙漠宝石中:

/usr/lib/ruby/gems/1.8/gems/desert-0.5.4/lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:24

原来是:

insert_sql = ActiveRecord::Base.send(:sanitize_sql, [ "INSERT INTO... 

有任何解决此问题的想法吗?

1 个答案:

答案 0 :(得分:0)

我有一个可以解决它的黑客攻击,但这很难看:

class Object
  # ActiveRecord::Base *is* an abstract class.
  unless defined?(abstract_class?)
    def abstract_class?
      true
    end
  end
end