我遇到了爲賽船會生成腳手架的問題。當我運行Rails 3拐點問題
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
相同的公共/樣式表/ 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
希望這將幫助別人的未來!
你如何修改文件? – 2011-06-09 22:38:57