pivotalexperimental / desert

Desert is a component framework for Rails that allows your plugins have a Rails app like directory structure, routes, migrations, and dependencies.
http://desert.rubyforge.org
186 stars 31 forks source link

Error undefined method `abstract_class?' #9

Open ghanshyamdrathod opened 14 years ago

ghanshyamdrathod commented 14 years ago

Hi I am using desert gem with community-engine plugin and tried to run rake db:migrate . i got following errors on the server.

rake aborted! undefined method abstract_class?' for Object:Class /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2207:inclass_of_active_record_descendant' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1462:in base_class' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1138:inreset_table_name' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1134:in table_name' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:3113:inquoted_table_name' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2226:in sanitize_sql' /usr/local/lib/ruby/gems/1.8/gems/desert-0.5.3/lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:23:insend' /usr/local/lib/ruby/gems/1.8/gems/desert-0.5.3/lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:23:in initialize_schema_migrations_table' /usr/local/lib/ruby/gems/1.8/gems/desert-0.5.3/lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:22:ineach' /usr/local/lib/ruby/gems/1.8/gems/desert-0.5.3/lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:22:in initialize_schema_migrations_table' /usr/local/lib/ruby/gems/1.8/gems/desert-0.5.3/lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:11:ineach' /usr/local/lib/ruby/gems/1.8/gems/desert-0.5.3/lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:11:in initialize_schema_migrations_table' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:436:ininitialize' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:400:in new' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:400:inup' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:383:in migrate' /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:116 /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:incall' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:ineach' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:ininvoke_with_call_chain' /usr/local/lib/ruby/1.8/monitor.rb:242:in synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:ineach' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:inrun' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:inrun' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31 /usr/local/bin/rake:19:in `load' /usr/local/bin/rake:19

taryneast commented 14 years ago

Me too. The problem is the line that begins: insert_sql = ActiveRecord::Base.send(:sanitize_sql, [

SQL queries seem no longer allowed on ActiveRecord::Base - you need to find an actual Active Record subclass because otherwise "abstract_class?" isn't yet defined... stupid really, ActiveRecord::Base#abstract_class? should exist and return true...

taryneast commented 14 years ago

I've solved it with a horrible monkey-patch:

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

taryneast monkey-patch originally worked for us - but it also broke the ability to use model finds in migrations. SomeModel.find(:all) fails with: SELECT * FROM bases