Skip to content
This repository
Browse code

don't reinitialize the arel_table unless the table_name changes

  • Loading branch information...
commit dc73c2c38feb018da37eda0a23c9411e15888eeb 1 parent 7cca6a2
Damien Mathieu dmathieu authored tenderlove committed

Showing 1 changed file with 2 additions and 1 deletion. Show diff stats Hide diff stats

  1. +2 1  activerecord/lib/active_record/base.rb
3  activerecord/lib/active_record/base.rb
@@ -659,6 +659,7 @@ def reset_sequence_name #:nodoc:
659 659 def set_table_name(value = nil, &block)
660 660 @quoted_table_name = nil
661 661 define_attr_method :table_name, value, &block
  662 + @arel_table = nil
662 663
663 664 @arel_table = Arel::Table.new(table_name, arel_engine)
664 665 @relation = Relation.new(self, arel_table)
@@ -892,7 +893,7 @@ def sti_name
892 893 end
893 894
894 895 def arel_table
895   - Arel::Table.new(table_name, arel_engine)
  896 + @arel_table ||= Arel::Table.new(table_name, arel_engine)
896 897 end
897 898
898 899 def arel_engine

0 comments on commit dc73c2c

Please sign in to comment.
Something went wrong with that request. Please try again.