aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-12-01 21:24:47 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-12-01 21:24:47 +0000
commit8ffb22056c2896a67917b813064b2247233d3a08 (patch)
tree770b069ec64cc067611e903d06471d60e6a0de9a /activerecord/lib/active_record/base.rb
parent2e2bf2d1494aa8b4efc4ff9e132dde4afd15ece1 (diff)
downloadrails-8ffb22056c2896a67917b813064b2247233d3a08.tar.gz
rails-8ffb22056c2896a67917b813064b2247233d3a08.tar.bz2
rails-8ffb22056c2896a67917b813064b2247233d3a08.zip
Subclasses of an abstract class work with single-table inheritance. Closes #5704.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5660 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 99c276ef8b..08df7e6f2e 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -816,7 +816,7 @@ module ActiveRecord #:nodoc:
end
def descends_from_active_record? # :nodoc:
- superclass == Base || !columns_hash.include?(inheritance_column)
+ superclass.abstract_class? || !columns_hash.include?(inheritance_column)
end
@@ -1161,7 +1161,7 @@ module ActiveRecord #:nodoc:
segments = []
segments << sanitize_sql(scope[:conditions]) if scope && scope[:conditions]
segments << sanitize_sql(conditions) unless conditions.nil?
- segments << type_condition unless descends_from_active_record?
+ segments << type_condition unless descends_from_active_record?
segments.compact!
sql << "WHERE (#{segments.join(") AND (")}) " unless segments.empty?
end
@@ -1362,7 +1362,7 @@ module ActiveRecord #:nodoc:
# Returns the class descending directly from ActiveRecord in the inheritance hierarchy.
def class_of_active_record_descendant(klass)
- if klass.superclass == Base || klass.superclass.abstract_class?
+ if klass.superclass.abstract_class?
klass
elsif klass.superclass.nil?
raise ActiveRecordError, "#{name} doesn't belong in a hierarchy descending from ActiveRecord"
@@ -1483,6 +1483,9 @@ module ActiveRecord #:nodoc:
end
end
+ # ActiveRecord::Base is abstract.
+ self.abstract_class = true
+
public
# New objects can be instantiated as either empty (pass no construction parameter) or pre-set with
# attributes but not yet saved (pass a hash with key names matching the associated table column names).