forked from cheald/mongomapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.rb
More file actions
15 lines (14 loc) · 811 Bytes
/
Copy pathinit.rb
File metadata and controls
15 lines (14 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# See http://groups.google.com/group/mongomapper/browse_thread/thread/68f62e8eda43b43a/4841dba76938290c
#
# to_prepare is called before each request in development mode and the first request in production.
Rails.configuration.to_prepare do
if !Rails.configuration.cache_classes
# Rails reloading was making descendants fill up and leak memory, these make sure they get cleared
MongoMapper::Document.descendants.each {|m| m.descendants.clear if m.respond_to?(:descendants) }
MongoMapper::Document.descendants.clear
MongoMapper::EmbeddedDocument.descendants.each {|m| m.descendants.clear if m.respond_to?(:descendants) }
MongoMapper::EmbeddedDocument.descendants.clear
MongoMapper::Plugins::IdentityMap.models.clear
end
end
config.middleware.use 'MongoMapper::Middleware::IdentityMap'