Skip to content
Browse files

Cache #arel_able when possible.

  • Loading branch information...
1 parent 60926db commit 0d6997b6e3f25d87b08b4aacaa2140609d5cc19c @miloops miloops committed Aug 18, 2009
Showing with 5 additions and 2 deletions.
  1. +5 −2 activerecord/lib/active_record/base.rb
View
7 activerecord/lib/active_record/base.rb
@@ -1533,9 +1533,12 @@ def merge_conditions(*conditions)
end
- def arel_table(table = nil)
+ def arel_table(table = nil, reload = nil)
table = table_name if table.blank?
- Relation.new(self, Arel::Table.new(table))
+ if reload || @arel_table.nil? || @arel_table.name != table
+ @arel_table = Relation.new(self, Arel::Table.new(table))
+ end
+ @arel_table
end
private

0 comments on commit 0d6997b

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