Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error undefined method `abstract_class?' #9

Open
ghanshyamdrathod opened this issue Jun 30, 2010 · 3 comments
Open

Error undefined method `abstract_class?' #9

ghanshyamdrathod opened this issue Jun 30, 2010 · 3 comments

Comments

@ghanshyamdrathod
Copy link

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
Copy link

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
Copy link

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
Copy link

smlsml commented Jan 18, 2011

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants