aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/active_support_overview.textile
diff options
context:
space:
mode:
Diffstat (limited to 'railties/guides/source/active_support_overview.textile')
-rw-r--r--railties/guides/source/active_support_overview.textile17
1 files changed, 8 insertions, 9 deletions
diff --git a/railties/guides/source/active_support_overview.textile b/railties/guides/source/active_support_overview.textile
index f7234b3383..10e098b029 100644
--- a/railties/guides/source/active_support_overview.textile
+++ b/railties/guides/source/active_support_overview.textile
@@ -890,15 +890,14 @@ The class +MissingSourceFile+ is a subclass of +LoadError+, so any code that res
For example, when an action of +PostsController+ is called Rails tries to load +posts_helper.rb+, but that file may not exist. That's fine, the helper module is not mandatory so Rails silences a load error. But it could be the case that the helper module does exist, but it in turn requires another library that is missing. In that case Rails must reraise the exception. The method +is_missing?+ provides a way to distinguish both cases:
<ruby>
-def inherited_with_helper(child)
- inherited_without_helper(child)
- begin
- child.master_helper_module = Module.new
- child.master_helper_module.__send__(:include, master_helper_module)
- child.helper child.name.to_s.underscore
- rescue MissingSourceFile => e
- raise unless e.is_missing?("#{child.name.to_s.underscore}_helper")
- end
+def default_helper_module!
+ module_name = name.sub(/Controller$/, '')
+ module_path = module_name.underscore
+ helper module_path
+rescue MissingSourceFile => e
+ raise e unless e.is_missing? "#{module_path}_helper"
+rescue NameError => e
+ raise e unless e.missing_name? "#{module_name}Helper"
end
</ruby>