diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-09-17 16:46:56 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2010-11-19 19:08:10 -0300 |
commit | a3210d90be844b306bbbf3324c7ad1ad389a14b9 (patch) | |
tree | fc7073dc58a34ed637d8648cd7df3d4588efeb90 | |
parent | c0ad5e48f643e9721059e94ba23dab3159eebb93 (diff) | |
download | rails-a3210d90be844b306bbbf3324c7ad1ad389a14b9.tar.gz rails-a3210d90be844b306bbbf3324c7ad1ad389a14b9.tar.bz2 rails-a3210d90be844b306bbbf3324c7ad1ad389a14b9.zip |
implicit_readonly is not set until records are loaded, just check readonly_value and then set readonly status.
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index b91ecb109a..500506506a 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -61,9 +61,7 @@ module ActiveRecord def to_a return @records if loaded? - readonly = @readonly_value.nil? ? @implicit_readonly : @readonly_value - - @records = if readonly + @records = if @readonly_value IdentityMap.without do eager_loading? ? find_with_associations : @klass.find_by_sql(arel.to_sql, @bind_values) end @@ -77,6 +75,7 @@ module ActiveRecord # @readonly_value is true only if set explicitly. @implicit_readonly is true if there # are JOINS and no explicit SELECT. + readonly = @readonly_value.nil? ? @implicit_readonly : @readonly_value @records.each { |record| record.readonly! } if readonly @loaded = true |