1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Another swing at reloading

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@479 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2005-01-24 00:26:44 +00:00
parent 0942bfa7a9
commit f31291ab5a
3 changed files with 13 additions and 15 deletions

View file

@ -78,8 +78,9 @@ module ActionController #:nodoc:
inherited_without_model(child) inherited_without_model(child)
return if child.controller_name == "application" # otherwise the ApplicationController in Rails will include itself return if child.controller_name == "application" # otherwise the ApplicationController in Rails will include itself
begin begin
child.model(Inflector.singularize(child.controller_name)) Object.const_get(child.controller_name.singularize.classify)
rescue LoadError child.model(child.controller_name.singularize)
rescue NameError, LoadError
# No neither singular or plural model available for this controller # No neither singular or plural model available for this controller
end end
end end

View file

@ -1,5 +1,7 @@
*SVN* *SVN*
* Fixed that models that weren't referenced in associations weren't being reloaded in the development mode by reinstating the reload
* Fixed that generate scaffold would produce bad functional tests * Fixed that generate scaffold would produce bad functional tests
* Fixed that FCGI can also display SyntaxErrors * Fixed that FCGI can also display SyntaxErrors

View file

@ -34,29 +34,24 @@ class Dispatcher
controller_name, module_name = controller_name(request.parameters), module_name(request.parameters) controller_name, module_name = controller_name(request.parameters), module_name(request.parameters)
require_dependency("application") require_or_load("application")
require_dependency(controller_path(controller_name, module_name)) require_or_load(controller_path(controller_name, module_name))
if Dependencies.mechanism == :load
ActiveRecord::Base.reset_column_information_and_inheritable_attributes_for_all_subclasses
Dependencies.reload
end
controller_class(controller_name).process(request, response).out controller_class(controller_name).process(request, response).out
rescue Object => exception rescue Object => exception
ActionController::Base.process_with_exception(request, response, exception).out ActionController::Base.process_with_exception(request, response, exception).out
ensure ensure
reset_application(controller_name) if Dependencies.mechanism == :load remove_class_hierarchy(controller_class(controller_name), ActionController::Base) if Dependencies.mechanism == :load
Breakpoint.deactivate_drb if defined?(BREAKPOINT_SERVER_PORT) Breakpoint.deactivate_drb if defined?(BREAKPOINT_SERVER_PORT)
end end
end end
private private
def reset_application(controller_name)
begin
remove_class_hierarchy(controller_class(controller_name), ActionController::Base)
ActiveRecord::Base.reset_column_information_and_inheritable_attributes_for_all_subclasses
Dependencies.reload
rescue Object => exception
# Compilation errors are caught on the first run through
end
end
def controller_path(controller_name, module_name = nil) def controller_path(controller_name, module_name = nil)
if module_name if module_name
"#{module_name}/#{Inflector.underscore(controller_name)}_controller" "#{module_name}/#{Inflector.underscore(controller_name)}_controller"