From 45137795e8db0c47c0bc16712b0a24807459e252 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 25 Mar 2005 09:07:01 +0000 Subject: [PATCH] Fixed that MissingSourceFile's wasn't properly detected in production mode #925 [Nicholas Seckar] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@990 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/dependencies.rb | 8 -------- actionpack/lib/action_controller/helpers.rb | 2 +- .../container/action_controller_container.rb | 2 +- activerecord/CHANGELOG | 2 ++ activesupport/lib/active_support/core_ext/load_error.rb | 6 +++++- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/actionpack/lib/action_controller/dependencies.rb b/actionpack/lib/action_controller/dependencies.rb index 7fb72417c0..2960330afa 100644 --- a/actionpack/lib/action_controller/dependencies.rb +++ b/actionpack/lib/action_controller/dependencies.rb @@ -82,14 +82,6 @@ module ActionController #:nodoc: def inherited(child) inherited_without_model(child) - return if child.controller_name == "application" # otherwise the ApplicationController in Rails will include itself - model_name = child.controller_name.singularize - begin - require_dependency model_name - child.model model_name - rescue MissingSourceFile => e - raise unless e.path == model_name + '.rb' - end end end end diff --git a/actionpack/lib/action_controller/helpers.rb b/actionpack/lib/action_controller/helpers.rb index 1db8a3ceba..ef58d38021 100644 --- a/actionpack/lib/action_controller/helpers.rb +++ b/actionpack/lib/action_controller/helpers.rb @@ -93,7 +93,7 @@ module ActionController #:nodoc: inherited_without_helper(child) begin child.helper(child.controller_path) rescue MissingSourceFile => e - raise unless e.path == "helpers/#{child.controller_path}_helper.rb" + raise unless e.is_missing?("helpers/#{child.controller_path}_helper") end end end diff --git a/actionwebservice/lib/action_web_service/container/action_controller_container.rb b/actionwebservice/lib/action_web_service/container/action_controller_container.rb index 12a566ef8e..06b47e9d79 100644 --- a/actionwebservice/lib/action_web_service/container/action_controller_container.rb +++ b/actionwebservice/lib/action_web_service/container/action_controller_container.rb @@ -86,7 +86,7 @@ module ActionWebService # :nodoc: inherited_without_api(child) begin child.web_service_api(child.controller_path) rescue MissingSourceFile => e - raise unless e.path == "apis/#{child.controller_path}_api.rb" + raise unless e.is_missing?("apis/#{child.controller_path}_api") end end end diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 74780f52dd..3f6fed17b5 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed that MissingSourceFile's wasn't properly detected in production mode #925 [Nicholas Seckar] + * Fixed that :counter_cache option would look for a line_items_count column for a LineItem object instead of lineitems_count * Fixed that AR exists?() would explode on postgresql if the passed id did not match the PK type #900 [Scott Barron] diff --git a/activesupport/lib/active_support/core_ext/load_error.rb b/activesupport/lib/active_support/core_ext/load_error.rb index 42f2d42e78..a04c4215d4 100644 --- a/activesupport/lib/active_support/core_ext/load_error.rb +++ b/activesupport/lib/active_support/core_ext/load_error.rb @@ -4,6 +4,10 @@ class MissingSourceFile < LoadError super(message) @path = path end + + def is_missing?(path) + path.gsub(/\.rb$/, '') == self.path.gsub(/\.rb$/, '') + end def self.from_message(message) REGEXPS.each do |regexp, capture| @@ -31,4 +35,4 @@ module ActiveSupport ::LoadError.extend(LoadErrorClassMethods) end end -end \ No newline at end of file +end