开发者

Rails 3 routing: singular option

开发者 https://www.devze.com 2023-02-16 22:41 出处:网络
You used to be a开发者_JAVA百科ble to do: resources :paises, :singular => :pais But I tried this in Rails and it didn\'t work. I want to have \'pais_path()\' for show and \'paises_path()\' for index

You used to be a开发者_JAVA百科ble to do:

resources :paises, :singular => :pais

But I tried this in Rails and it didn't work. I want to have 'pais_path()' for show and 'paises_path()' for index.

thanks


open your config/initializers/inflections.rb file and add this

ActiveSupport::Inflector.inflections do |inflect|
  inflect.irregular 'pais', 'paises'
end

then your route resources :paises will work for you as expected

0

精彩评论

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