开发者

Routes in Rails with controllers that end in 's'

This is just cosmetic but still driving me nuts. I've created a controller for my Address object and try to lay out routes for it. However, Rails seems to interpret the last 's' as plural and removes it from my paths, like this:

routes.rb:

resources :address
开发者_运维问答

(note: this line is inside a namespace block called 'admin')

When I run rake routes I get this:

new_admin_addres
edit_admin_addres

... and so on. How do I get the extra 's' in my paths?


resources :addresses which is the plural of address


Use the inflections to set address to be uncountable: config/initializers/inflections.rb

ActiveSupport::Inflector.inflections do |inflect|
   inflect.uncountable %w( address )
end

This should now ignore any extra 's'. Not gramatically correct but should solve the issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜