aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-08-27 18:52:14 -0300
committerEmilio Tagua <miloops@gmail.com>2009-08-27 18:52:14 -0300
commit7cce95b25ace33e04526d4490e487a080c1f9b96 (patch)
treedfc105d13590e6d5b50d6fc689e18f77d7a750c2 /activerecord/lib/active_record/base.rb
parentd56e987757923fa28ae90cf269707b78b744d66d (diff)
downloadrails-7cce95b25ace33e04526d4490e487a080c1f9b96.tar.gz
rails-7cce95b25ace33e04526d4490e487a080c1f9b96.tar.bz2
rails-7cce95b25ace33e04526d4490e487a080c1f9b96.zip
Add readonly support for relations.
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index c11c049415..402d68c36e 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1722,7 +1722,7 @@ module ActiveRecord #:nodoc:
def construct_finder_arel(options = {}, scope = scope(:find))
# TODO add lock to Arel
- arel_table(options[:from]).
+ relation = arel_table(options[:from]).
joins(construct_join(options[:joins], scope)).
conditions(construct_conditions(options[:conditions], scope)).
select(options[:select] || (scope && scope[:select]) || default_select(options[:joins] || (scope && scope[:joins]))).
@@ -1730,6 +1730,11 @@ module ActiveRecord #:nodoc:
order(construct_order(options[:order], scope)).
limit(construct_limit(options[:limit], scope)).
offset(construct_offset(options[:offset], scope))
+
+ relation = relation.readonly if options[:readonly]
+
+ relation
+
end
def construct_finder_sql(options, scope = scope(:find))