Modules included in Helper modules won't be included
Reported by Carl Lerche | June 15th, 2008 @ 11:35 PM | in 0.9.4
Here's the problem. Merb::BootLoader::LoadClasses loads controllers before helpers.
In AbstractController, there is the following:
def inherited(klass)
_abstract_subclasses << klass.to_s
helper_module_name = klass.to_s =~ /^(#|Merb::)/ ? "#{klass}Helper" : "Merb::#{klass}Helper"
Object.make_module helper_module_name
klass.class_eval <<-HERE
include Object.full_const_get("#{helper_module_name}") rescue nil
HERE
super
end
This creates the helper module for the controller and includes it into the controller before the helpers even get loaded. This causes two problems.
- The included class method in the module will never get called because the module was already included
- Any module that is included in the helper module will not get included into the controller because the Helper module is already included into the controller.
Comments and changes to this ticket
-
Carl Lerche June 15th, 2008 @ 11:46 PM
This could be fixed by loading the helpers path before the controllers path.
I think it might be a good idea to make the order in which paths are loaded customizable.
Merb::BootLoader::LoadClasses.order = [:lib, :models, :helpers, :controllers]Then, anything that isn't specified gets loaded after.
-
Carl Lerche June 16th, 2008 @ 12:08 AM
Apparently you can change the load order by simply rebuilding your own framework (Check the BuildFramework boot loader).
To fix this, I simply swapped the order of helper and controller in the default framework. See patch
-
Ezra Zygmuntowicz June 18th, 2008 @ 03:14 AM
- → Milestone changed from to 0.9.4
- → State changed from new to resolved
- → Assigned user changed from to Ezra Zygmuntowicz
applied thanks
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
