升级Rails 3.2到4.2.6,路由会为资源生成错误的路径名

时间:2016-04-13 20:40:43

标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4

我从Rails 3.2升级到4.2.6,并且由于某种原因,一个模型突然发现它的rails生成的资源路径名都错了。所有其他模型的资源都运行良好。

routes.rb(注释掉隔离故障模型的所有其他路由)

Rails.application.routes.draw do
  resources :signups
end

rails 3.2 rake routes输出(它看起来应该是什么样的)

signups     GET     /signups(.:format)          signups#index
            POST    /signups(.:format)          signups#create
new_signup  GET     /signups/new(.:format)      signups#new
edit_signup GET     /signups/:id/edit(.:format) signups#edit
signup      GET     /signups/:id(.:format)      signups#show
            PUT     /signups/:id(.:format)      signups#update
            DELETE  /signups/:id(.:format)      signups#destroy

rails 4.2.6 rake routes输出

signups_index GET    /signups(.:format)          signups#index
              POST   /signups(.:format)          signups#create
  new_signups GET    /signups/new(.:format)      signups#new
 edit_signups GET    /signups/:id/edit(.:format) signups#edit
      signups GET    /signups/:id(.:format)      signups#show
              PATCH  /signups/:id(.:format)      signups#update
              PUT    /signups/:id(.:format)      signups#update
              DELETE /signups/:id(.:format)      signups#destroy

知道什么可能导致这个模型改变了它的路径名?

1 个答案:

答案 0 :(得分:1)

inflect.irregular('signup', 'signups')添加到config/initializers/inflections.rb