I ask because I would like to use Spring to preload my fixtures prior to 
forking. (It's taking about 6 seconds to load ~300 fixture files)

However, after forking, ActiveRecord::Base returns a new connection 
(probably because one needs to establish a new connection after forking).
This meant that FixtureSet.cache_for_connection returned nil even though 
there is a class level fixture cache.

The following monkey-patch gives me the cached fixtures again.

+    ActiveRecord::FixtureSet.class_eval do

+      # spring reconnects - this results in a new 
ActiveRecord::Base.connection object

+      def self.cache_for_connection(connection)

+        
ActiveRecord::FixtureSet.class_variable_get(:@@all_cached_fixtures).values.only

+      end

+    end



I found this commit which I could not see an answer for my question 
:https://github.com/rails/rails/commit/078bd0515e8342165a4bc3b8fcc4faa318ebb188


Could it be for multiple databases or something like multi-threading ? 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to