【发布时间】:2015-12-28 19:49:23
【问题描述】:
将应用程序从 Rails 2 迁移到 4,因为我的服务器通过 rails 应用程序被黑客入侵,因此出于安全原因我正在升级。在我的代码中,我有这一行:
lawyer_show_url = "<%= url_for(:controller => 'lawyers', :action => 'show') %>";
我现在收到此错误消息:
ActionView::Template::Error (No route matches {:action=>"show", :controller=>"lawyers"}):
在 config/routes.rb 中,带有 rails 2 和 4,我有这一行:
resource :lawyers
我的旧 config/routes.rb 文件也有臭名昭著的包罗万象:
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
但我知道在 rails 4 中没有这样的代码。 如何在 rails 4 中为我的资源生成 URL?
【问题讨论】: