0

我的大脑正在煎熬,试图在假期前挤一些工作。

我正在尝试修复一个简单的错误。以下 link_to_remote 创建的 URL 错误:

options = {
    :url => { :controller => 'favorites', :action => 'resort', :params => params.merge({:sort => key, :method => method})},
    :update => 'favorites'
}
html_options = {
  :title => "Sort by this field",
  :href => url_for(:controller => 'favorites', :action => 'resort', :params => params.merge({:sort => key, :method => method}))
}
link_to_remote("hithere", options, html_options)

它正在创建:

http://localhost:3000/favorites?method=ASC&sort=title

代替:

http://localhost:3000/favorites/resort?method=ASC&sort=title

指定的路线是:

  map.favorites_resort           "/favorites/resort",                                    :controller => "favorites", :action => "resort"
  map.favorites_search           "/favorites/search",                                    :controller => "favorites", :action => "search"
  map.toggle_message_favorite    "/favorites/toggle_message_favorite/:message_id",       :controller => "favorites", :action => "toggle_message_favorite"
  map.toggle_attachment_favorite "/favorites/toggle_attachment_favorite/:attachment_id", :controller => "favorites", :action => "toggle_attachment_favorite"
  map.resources :favorites

我的猜测是它与一些路由优先级有关,但我不知道是哪个...谢谢!

根据 jasnow 的建议,将路线更改为: map.favorites_resort "/favorites/resort/sort/:sort/method/:method"

4

1 回答 1

1

在路由文件中查找“/:”。

于 2009-12-31T22:21:03.473 回答