Skip to content
This repository
Browse code

Moved the global require_* out of the classes so they actually work w…

…ithout stack overflows

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@33 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit d6d875bfb4103b6ac777083946bdcfa527d750a8 1 parent d82f73e
David Heinemeier Hansson authored November 30, 2004
6  actionpack/lib/action_controller/base.rb
@@ -5,6 +5,10 @@
5 5
 require 'action_controller/support/class_inheritable_attributes'
6 6
 require 'action_controller/support/inflector'
7 7
 
  8
+unless Object.respond_to?(:require_dependency)
  9
+  Object.send(:define_method, :require_dependency) { |file_name| ActionController::Base.require_dependency(file_name) }
  10
+end
  11
+
8 12
 module ActionController #:nodoc:
9 13
   class ActionControllerError < StandardError #:nodoc:
10 14
   end
@@ -259,8 +263,6 @@ def controller_name
259 263
       def require_dependency(file_name)
260 264
         reload_dependencies ? silence_warnings { load("#{file_name}.rb") } : require(file_name)
261 265
       end
262  
-
263  
-      Object.send(:define_method, :require_dependency) { |file_name| ActiveRecord::Base.require_dependency(file_name) }
264 266
     end
265 267
 
266 268
     public
8  activerecord/lib/active_record/base.rb
@@ -3,6 +3,10 @@
3 3
 require 'active_record/support/inflector'
4 4
 require 'yaml'
5 5
 
  6
+unless Object.respond_to?(:require_association)
  7
+  Object.send(:define_method, :require_association) { |file_name| ActiveRecord::Base.require_association(file_name) }
  8
+end
  9
+
6 10
 module ActiveRecord #:nodoc:
7 11
   class ActiveRecordError < StandardError #:nodoc:
8 12
   end
@@ -553,9 +557,7 @@ def require_association(file_name)
553 557
         end
554 558
       end
555 559
       
556  
-      Object.send(:define_method, :require_association) { |file_name| ActiveRecord::Base.require_association(file_name) }
557  
-      
558  
-      # Resets the list of dependencies loaded (typically to be called by the end of a request), so when require_or_load is
  560
+      # Resets the list of dependencies loaded (typically to be called by the end of a request), so when require_association is
559 561
       # called for that dependency it'll be loaded anew.
560 562
       def reset_associations_loaded
561 563
         associations_loaded = []

0 notes on commit d6d875b

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