我有一个名为ActiveDns的模型.当我跑
rails g scaffold_controller ActiveDns@H_502_4@我收到消息
@H_502_4@Plural version of the model detected,using singularized version. Override with –force-plural.@H_502_4@现在,控制器和视图被假定为单数为ActiveDn,复数为ActiveDns,并且我会收到像“link_to new_dn_path”这样的愚蠢的东西. –force-plural参数似乎没有解决这个问题:
rails g scaffold_controller ActiveDns --force-plural@H_502_4@仍然导致控制器使用名为@active_dn的变量和使用new_dn_path的视图,带有rails 3.2.3.我正在使用rails d scaffold_controller ActiveDns删除尝试之间的文件. @H_502_4@这样做的正确方法是什么?
解决方法
@H_502_4@What’s the right way to do this?@H_502_4@我使用inflections到document不可数实体.
@H_502_4@config/initializers/inflections.rb
ActiveSupport::Inflector.inflections do |inflect| inflect.uncountable "ActiveDns" end@H_502_4@然后你得到:
$rails g scaffold_controller ActiveDns create app/controllers/active_dns_controller.rb invoke erb create app/views/active_dns create app/views/active_dns/index.html.erb create app/views/active_dns/edit.html.erb create app/views/active_dns/show.html.erb create app/views/active_dns/new.html.erb create app/views/active_dns/_form.html.erb invoke test_unit create test/functional/active_dns_controller_test.rb invoke helper create app/helpers/active_dns_helper.rb invoke test_unit create test/unit/helpers/active_dns_helper_test.rb@H_502_4@这是你想要的吗?