开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜