Rails 3 autoload_paths versus Rails 2 load_paths
So, I figured out that I nee开发者_C百科ded to change my config.load_paths
to config.autoload_paths
but when I did that, I start seeing this exception:
Expected /path/to/myapp/app/helpers/controllers/my_helper.rb to define Controllers::MyHelper
In Rails 2, it never complained about the helpers/controllers folder, but now it seems that it expects a namespaced module. Do I have rename all of my helpers, or is there some other way this can work? I have so many helpers that I use helpers/models helpers/views and helpers/controllers to keep them all organized.
Thanks in advance!
Rails 3 does expect your classes to be namespaced according to file name and directory hierarchy, so you will have to rename your helper to Controllers::MyHelper
.
File naming conventions in Rails 3 are a lot more strict than they were in Rails 2 for performance reasons. Rails 3 expects the file structure to directly match the class hierarchy.
If you would like the run the application in Rails 3 I would suggest removing the helpers directory or adding Controllers::
to the front of each class declaration.
精彩评论