diff options
Diffstat (limited to 'activerecord/lib/active_record/associations/association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/association.rb | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index 624942d08a..4b989793da 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -82,7 +82,7 @@ module ActiveRecord end def scoped - target_scope.merge(association_scope).merge(reflection_scope) + target_scope.merge(association_scope) end # The scope for this association. @@ -101,10 +101,6 @@ module ActiveRecord @association_scope = nil end - def reflection_scope - reflection.scope && klass.instance_exec(&reflection.scope) - end - # Set the inverse association, if possible def set_inverse_instance(record) if record && invertible_for?(record) @@ -152,6 +148,21 @@ module ActiveRecord end end + # We can't dump @reflection since it contains the scope proc + def marshal_dump + reflection = @reflection + @reflection = nil + + ivars = instance_variables.map { |name| [name, instance_variable_get(name)] } + [reflection.name, ivars] + end + + def marshal_load(data) + reflection_name, ivars = data + ivars.each { |name, val| instance_variable_set(name, val) } + @reflection = @owner.class.reflect_on_association(reflection_name) + end + private def find_target? |