Skip to content

Commit

Permalink
implicit_readonly is not set until records are loaded, just check rea…
Browse files Browse the repository at this point in the history
…donly_value and then set readonly status.
  • Loading branch information
miloops committed Nov 19, 2010
1 parent c0ad5e4 commit a3210d9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions activerecord/lib/active_record/relation.rb
Expand Up @@ -61,9 +61,7 @@ def respond_to?(method, include_private = false)
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
Expand All @@ -77,6 +75,7 @@ def to_a

# @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
Expand Down

0 comments on commit a3210d9

Please sign in to comment.