我打的Rails 4.1.4中的錯誤是最近由固定Rails核心:Fix potenital infinite recursion in changed_for_autosave? #16640應用Rails核心固定本地
我怎麼能暫時在這個局部修復補丁,直到我已經升級到Rails的版本有這個?解決方法是更改了activerecord/LIB/active_record/autosave_association.rb
我已經有AR ::基地的擴展,我從包括本身經由ActiveRecord::Base.send(:include, ActiveRecordExtension)
我試圖增加一個模塊內聯的初始化調用在該文件中用於更改方法的AutosaveAssociation。
更新
配置/ intializers/01_extensions.rb
require "active_record_extension"
active_record_extension.rb
module ActiveRecordExtension
extend ActiveSupport::Concern
module ClassMethods
...
end
module AutosaveAssociation
def nested_records_changed_for_autosave?
return false if @_nested_records_changed_for_autosave_already_called ||= false
@_nested_records_changed_for_autosave_already_called = true
begin
self.class._reflections.values.any? do |reflection|
if reflection.options[:autosave]
association = association_instance_get(reflection.name)
association && Array.wrap(association.target).any? { |a| a.changed_for_autosave? }
end
end
ensure
@_nested_records_changed_for_autosave_already_called = false
end
end
end # module Autosave
end
ActiveRecord::Base.send(:include, ActiveRecordExtension)
你的初始值設定項/擴展名是什麼樣的? – wpp 2014-08-28 09:42:11
現在補充問題。 – rigyt 2014-08-28 22:22:21