aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/dependencies.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/dependencies.rb')
-rw-r--r--actionpack/lib/action_controller/dependencies.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/dependencies.rb b/actionpack/lib/action_controller/dependencies.rb
index 1deaf0ce4b..7fb72417c0 100644
--- a/actionpack/lib/action_controller/dependencies.rb
+++ b/actionpack/lib/action_controller/dependencies.rb
@@ -71,8 +71,8 @@ module ActionController #:nodoc:
dependencies.flatten.each do |dependency|
begin
require_dependency(dependency.to_s)
- rescue LoadError
- raise LoadError, "Missing #{layer} #{dependency}.rb"
+ rescue LoadError => e
+ raise LoadError.new("Missing #{layer} #{dependency}.rb").copy_blame!(e)
rescue Object => exception
exception.blame_file! "=> #{layer} #{dependency}.rb"
raise
@@ -83,12 +83,14 @@ 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
- child.model(child.controller_name.singularize)
- rescue NameError, LoadError
- # No neither singular or plural model available for this controller
+ require_dependency model_name
+ child.model model_name
+ rescue MissingSourceFile => e
+ raise unless e.path == model_name + '.rb'
end
end
end
end
-end \ No newline at end of file
+end