在我的 rails 应用程序中,出于某种原因,我必须将我的 URL 重定向到所需的 URL。
这就是我的配置设置routes.rb.
map.connect 'sample/:action/:id.:format', :controller => 'test'
当 url 为http://example.com/sample时,它会很好地重定向。它
Test采用控制器索引方法。当 url 为http://example.com/sample/displayname?id=10时,它会转到
Test控制器并搜索displayname方法。显然它不存在,所以我收到了“undefined”错误消息。
在这里,即使 URL 是(http://example.com/sample/displayname?id=10),我也想要它足够去Test控制器的索引方法。同样在地址栏中我想要 URL 掩码。如果我点击http://example.com/sample/ 它应该重定向 & 在地址栏中http://example.com/test。
我如何使用 Rails-2 应用程序(Rails 版本 2.3.9)做到这一点?