Merge pull request #242 from SamSaffron/fix

this little bit of caching gives us a massive perf gain on Discourse
This commit is contained in:
Steve Klabnik 2013-03-18 17:27:16 -07:00
commit 5d2ae9b138

View File

@ -17,6 +17,14 @@ module ActiveModel
end
self.options = class_options
# cache the root so we can reuse it without falling back on a per-instance basis
begin
self.options[:root] ||= self.new(name, nil).root
rescue
# this could fail if it needs a valid source, for example a polymorphic association
end
end
end