Skip to content
This repository
Browse code

Correct spelling of persistent [Stefan Kaes]. Document and eliminate …

…warnings in clear_persistent_model_associations.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3166 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 202e4208c4d26f05ea856dbd57f4843ee3a7db29 1 parent e8f664d
Jeremy Kemper jeremy authored

Showing 1 changed file with 15 additions and 5 deletions. Show diff stats Hide diff stats

  1. +15 5 actionpack/lib/action_controller/session_management.rb
20 actionpack/lib/action_controller/session_management.rb
@@ -11,7 +11,7 @@ def self.append_features(base)
11 11 base.extend(ClassMethods)
12 12 base.send(:alias_method, :process_without_session_management_support, :process)
13 13 base.send(:alias_method, :process, :process_with_session_management_support)
14   - base.after_filter(:clear_persistant_model_associations)
  14 + base.after_filter(:clear_persistent_model_associations)
15 15 end
16 16
17 17 module ClassMethods
@@ -115,11 +115,21 @@ def process_with_session_management_support(request, response, method = :perform
115 115 request.session_options = self.class.session_options_for(request, action)
116 116 process_without_session_management_support(request, response, method, *arguments)
117 117 end
118   -
  118 +
119 119 private
120   - def clear_persistant_model_associations #:doc:
121   - if session = @session.instance_variable_get("@data")
122   - session.each { |key, obj| obj.clear_association_cache if obj.respond_to?(:clear_association_cache) }
  120 + # Clear cached associations in session data so they don't overflow
  121 + # the database field. Only applies to ActiveRecordStore since there
  122 + # is not a standard way to iterate over session data.
  123 + def clear_persistent_model_associations #:doc:
  124 + if defined?(@session) and @session.instance_variables.include?('@data')
  125 + session_data = @session.instance_variable_get('@data')
  126 + if session_data and session_data.respond_to?(:each_value)
  127 + session_data.each_value do |obj|
  128 + if obj.respond_to?(:clear_association_cache)
  129 + obj.clear_association_cache
  130 + end
  131 + end
  132 + end
123 133 end
124 134 end
125 135 end

0 comments on commit 202e420

Please sign in to comment.
Something went wrong with that request. Please try again.