提交 fa1f5e06 编写于 作者: D David Heinemeier Hansson

Switch dispatcher to use the new shared Dependencies approach

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@280 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 595a4a59
......@@ -226,15 +226,6 @@ def self.inherited(child) #:nodoc:
cattr_accessor :default_timezone
@@default_timezone = :local
# When turned on (which is default), all associations are included using "load". This mean that any change is instant in cached
# environments like mod_ruby or FastCGI. When set to false, "require" is used, which is faster but requires server restart to
# reflect changes.
@@reload_associations = true
cattr_accessor :reload_associations
@@associations_loaded = []
cattr_accessor :associations_loaded
class << self # Class methods
# Returns objects for the records responding to either a specific id (1), a list of ids (1, 5, 6) or an array of ids.
# If only one ID is specified, that object is returned directly. If more than one ID is specified, an array is returned.
......
Dependencies.mechanism = :load
ActionController::Base.consider_all_requests_local = true
ActionController::Base.reload_dependencies = true
ActiveRecord::Base.reload_associations = true
BREAKPOINT_SERVER_PORT = 42531
\ No newline at end of file
Dependencies.mechanism = :require
ActionController::Base.consider_all_requests_local = false
ActionController::Base.reload_dependencies = false
ActiveRecord::Base.reload_associations = false
Dependencies.mechanism = :require
ActionController::Base.consider_all_requests_local = true
ActionController::Base.reload_dependencies = false
ActiveRecord::Base.reload_associations = false
ActionMailer::Base.delivery_method = :test
\ No newline at end of file
......@@ -40,11 +40,11 @@ def self.dispatch(cgi = CGI.new, session_options = ActionController::CgiRequest:
rescue Object => exception
ActionController::Base.process_with_exception(request, response, exception).out
ensure
if ActionController::Base.reload_dependencies
if Dependencies.mechanism == :load
Object.send(:remove_const, "ApplicationController") if Object.const_defined?(:ApplicationController)
Object.send(:remove_const, controller_class_name(controller_name)) if Object.const_defined?(controller_class_name(controller_name))
ActiveRecord::Base.reset_column_information_and_inheritable_attributes_for_all_subclasses
ActiveRecord::Base.reload_associations_loaded
Dependencies.reload
end
Breakpoint.deactivate_drb if defined?(BREAKPOINT_SERVER_PORT)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册