aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-11-09 19:31:31 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-11-09 19:31:31 +0000
commit9d2da04680db202ba006ff66199b345a3f29b2cb (patch)
treecb2707e167905ae9a8639c4650a5bcca5fcf84ac /activerecord/lib/active_record/base.rb
parent0342393b30e46a5a6433420e9e1b192ec65f8a11 (diff)
downloadrails-9d2da04680db202ba006ff66199b345a3f29b2cb.tar.gz
rails-9d2da04680db202ba006ff66199b345a3f29b2cb.tar.bz2
rails-9d2da04680db202ba006ff66199b345a3f29b2cb.zip
Cache inheritance_column. Closes #6592.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5474 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, 5 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index c35453f326..864cf43ef3 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -648,9 +648,10 @@ module ActiveRecord #:nodoc:
key
end
- # Defines the column name for use with single table inheritance -- can be overridden in subclasses.
+ # Defines the column name for use with single table inheritance
+ # -- can be set in subclasses like so: self.inheritance_column = "type_id"
def inheritance_column
- "type"
+ @inheritance_column ||= "type".freeze
end
# Lazy-set the sequence name to the connection's default. This method
@@ -800,7 +801,7 @@ module ActiveRecord #:nodoc:
# Resets all the cached information about columns, which will cause them to be reloaded on the next request.
def reset_column_information
read_methods.each { |name| undef_method(name) }
- @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = nil
+ @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = @inheritance_column = nil
end
def reset_column_information_and_inheritable_attributes_for_all_subclasses#:nodoc:
@@ -1057,7 +1058,7 @@ module ActiveRecord #:nodoc:
# Ignore type if no column is present since it was probably
# pulled in from a sloppy join.
- unless self.columns_hash.include?(inheritance_column)
+ unless columns_hash.include?(inheritance_column)
allocate
else