Rails 2.3.0更改了ApplicationController类的文件名

2008年11月22日 | 分类: 编程开发 | 标签: , ,

  ApplicationController是Rails中控制器的基类,在Rails 2.3.0之前,ApplicationController类保存于app/controllers/application.rb文件中,而在Rails 2.3.0中,这个类被保存于app/controllers/application_controller.rb这个文件中。

  这样相对于application_helper.rb助手类,在命名风格上就更加统一了,如果你的Rails项目是使用Rails 2.3.0之前的版本生成的,当你将Rails库更新到Rails 2.3.0之后,就需要手动将app/controllers/application.rb手动更名为app/controllers/application_controller.rb。

  如果不更改文件名的话,系统则会提示错误:

uninitialized constant ApplicationController

  DHH大神在CHANGELOG里是这么写的:* BACKWARDS INCOMPATIBLE: Renamed application.rb to application_controller.rb and removed all the special casing that was in place to support the former. You must do this rename in your own application when you upgrade to this version [DHH]

  1. 谢谢,总算正郁闷来着,总算解决了