aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-08-18 14:49:11 -0300
committerEmilio Tagua <miloops@gmail.com>2009-08-18 14:49:11 -0300
commit0d6997b6e3f25d87b08b4aacaa2140609d5cc19c (patch)
tree726946670ade82ba635592d6dd8d8de1b1bc46c3 /activerecord
parent60926db9e06a7890409926211dffe773aff4a57d (diff)
downloadrails-0d6997b6e3f25d87b08b4aacaa2140609d5cc19c.tar.gz
rails-0d6997b6e3f25d87b08b4aacaa2140609d5cc19c.tar.bz2
rails-0d6997b6e3f25d87b08b4aacaa2140609d5cc19c.zip
Cache #arel_able when possible.
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record/base.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index b23ce53d43..3bbe23865f 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1533,9 +1533,12 @@ module ActiveRecord #:nodoc:
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