我正在用西类牙语开发应用程序,所以我不得不修改一些表格的复数规则,在表格城市中我有这个:
ActiveSupport::Inflector.inflections do |inflect|
inflect.plural /ciudad$/i, '\1ciudades'
inflect.singular /ciudades/i, '\1ciudad'
end
我已经测试了复数设置:
"ciudad".pluralization
ciudades
运行脚手架
rails generate scaffold ciudad nombre:string departamento_id:integer
最后一次迁移
rake 数据库:迁移
但打开 url http://localhost:3000/ciudades服务器 View
Routing Error
No route matches "/ciudades"
rake 路
ciudades GET /ciudades(.:format) {:controller=>"ciudades", :action=>"index"}
POST /ciudades(.:format) {:controller=>"ciudades", :action=>"create"}
new_ciudad GET /ciudades/new(.:format) {:controller=>"ciudades", :action=>"new"}
edit_ciudad GET /ciudades/:id/edit(.:format) {:controller=>"ciudades", :action=>"edit"}
ciudad GET /ciudades/:id(.:format) {:controller=>"ciudades", :action=>"show"}
PUT /ciudades/:id(.:format) {:controller=>"ciudades", :action=>"update"}
DELETE /ciudades/:id(.:format) {:controller=>"ciudades", :action=>"destroy"}
departamentos GET /departamentos(.:format) {:controller=>"departamentos", :action=>"index"}
POST /departamentos(.:format) {:controller=>"departamentos", :action=>"create"}
new_departamento GET /departamentos/new(.:format) {:controller=>"departamentos", :action=>"new"}
edit_departamento GET /departamentos/:id/edit(.:format) {:controller=>"departamentos", :action=>"edit"}
departamento GET /departamentos/:id(.:format) {:controller=>"departamentos", :action=>"show"}
PUT /departamentos/:id(.:format) {:controller=>"departamentos", :action=>"update"}
DELETE /departamentos/:id(.:format) {:controller=>"departamentos", :action=>"destroy"}
tipo_terceros GET /tipo_terceros(.:format) {:controller=>"tipo_terceros", :action=>"index"}
POST /tipo_terceros(.:format) {:controller=>"tipo_terceros", :action=>"create"}
new_tipo_tercero GET /tipo_terceros/new(.:format) {:controller=>"tipo_terceros", :action=>"new"}
edit_tipo_tercero GET /tipo_terceros/:id/edit(.:format) {:controller=>"tipo_terceros", :action=>"edit"}
tipo_tercero GET /tipo_terceros/:id(.:format) {:controller=>"tipo_terceros", :action=>"show"}
PUT /tipo_terceros/:id(.:format) {:controller=>"tipo_terceros", :action=>"update"}
DELETE /tipo_terceros/:id(.:format) {:controller=>"tipo_terceros", :action=>"destroy"}
最佳答案
在你的变形器中使用它:
ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular 'ciudad', 'ciudades'
end
关于ruby - 没有路由匹配 "/ciudades",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7018833/