Skip to content

Instantly share code, notes, and snippets.

@dbrady
Created October 17, 2011 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbrady/1291906 to your computer and use it in GitHub Desktop.
Save dbrady/1291906 to your computer and use it in GitHub Desktop.
ActiveRecord models deny their ancestry. What gives?
class Bonk < ActiveRecord::Base
end
Bonk.ancestors.include? ActiveRecord::Base
# => true
Bonk.is_a? ActiveRecord::Base
# => false
# um...WAT
# X.is_a? Y should return true if Y is a superclass of X or
# if Y is a module included by X. So, um... what gives?
# lolrails?
@eltiare
Copy link

eltiare commented Oct 17, 2011

Shame was my first guess.

@dbrady
Copy link
Author

dbrady commented Oct 17, 2011

Answer thanks to @jm on Twitter: Bonk.is_a? won't work, but Bonk.new.is_a? DOES. You have to use it on instances, not their classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment