我在为帆船赛生成脚手架时遇到了问题.我跑的时候
rails g scaffold Regatta name:string start_date:datetime
我得到一个名为regattum的模型和一个名为regatta_controller的控制器(而不是regattas_controller)
invoke active_record create db/migrate/20110609221608_create_regatta.rb create app/models/regattum.rb invoke test_unit create test/unit/regattum_test.rb create test/fixtures/regatta.yml route resources :regatta invoke scaffold_controller create app/controllers/regatta_controller.rb invoke erb create app/views/regatta create app/views/regatta/index.html.erb create app/views/regatta/edit.html.erb create app/views/regatta/show.html.erb create app/views/regatta/new.html.erb create app/views/regatta/_form.html.erb invoke test_unit create test/functional/regatta_controller_test.rb invoke helper create app/helpers/regatta_helper.rb invoke test_unit create test/unit/helpers/regatta_helper_test.rb invoke stylesheets
相同的public / stylesheets / scaffold.css
显然这是一个变形问题,但每当我修改/config/initializers/inflections.rb时,我都会收到错误消息:
The name 'Regatta' is either already used in your application or reserved by Ruby on Rails. Please choose an alternative and run this generator again.
我已经尝试了一切我能想到的功能,但我一直都会遇到错误.任何有关解决方案或变通方法的建议都将不胜感激!
更新
以下是我尝试过的一些事情:
ActiveSupport::Inflector.inflections do |inflect| inflect.irregular 'regatta','regattas' end
这并没有改变任何东西,所以我尝试了下面的一些选项,其中包括不同的组合无济于事:
inflect.plural 'regatta','regattas' inflect.singular 'regattas','regatta' inflect.singular 'regatta','regatta'
更新2
这是我在inflections.rb中使用的代码,一旦我弄清楚我做错了什么:
ActiveSupport::Inflector.inflections do |inflect| inflect.plural 'regatta','regattas' inflect.singular 'regatta','regatta' inflect.singular 'regattas','regatta' end
希望这将有助于将来的人!