Created
September 11, 2013 14:57
-
-
Save kazuhisa/6524819 to your computer and use it in GitHub Desktop.
Rails4.0.0でJoinしたテーブルに対してreadonly(false)が効かないのはバグです。4.1系で解消されるはずなので、次のパッチをconfig/initializersにでも入れておくといいよ。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
module ActiveRecord | |
class Relation | |
def initialize(klass, table, values = {}) | |
@klass = klass | |
@table = table | |
@values = values | |
@loaded = false | |
end | |
private | |
def exec_queries | |
@records = eager_loading? ? find_with_associations : @klass.find_by_sql(arel, bind_values) | |
preload = preload_values | |
preload += includes_values unless eager_loading? | |
preload.each do |associations| | |
ActiveRecord::Associations::Preloader.new(@records, associations).run | |
end | |
@records.each { |record| record.readonly! } if readonly_value | |
@loaded = true | |
@records | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment