diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-08-18 14:49:11 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-08-18 14:49:11 -0300 |
commit | 0d6997b6e3f25d87b08b4aacaa2140609d5cc19c (patch) | |
tree | 726946670ade82ba635592d6dd8d8de1b1bc46c3 /activerecord | |
parent | 60926db9e06a7890409926211dffe773aff4a57d (diff) | |
download | rails-0d6997b6e3f25d87b08b4aacaa2140609d5cc19c.tar.gz rails-0d6997b6e3f25d87b08b4aacaa2140609d5cc19c.tar.bz2 rails-0d6997b6e3f25d87b08b4aacaa2140609d5cc19c.zip |
Cache #arel_able when possible.
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 7 |
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 |