1

モデルの関連付けを表示するためにwill_paginateを使用しています。次のようにカスタムルートを設定します。

get '/profile/:slug' => 'talents#show', :as => :talent
get '/profile/:slug/bio' => 'talents#show', :as => :talent_bio
get '/profile/:slug/instagram' => 'talents#show', :as => :talent_instagram

talent_instagram routeを使用している場合、代わりにすべてのページネーションリンクがデフォルトルートにレンダリングされます。つまり、次の代わりに:

http:://0.0.0.0:3000/profile/some-talent/instagram?page=5

これが私たちが得るものです:

http:://0.0.0.0:3000/profile/some-talent?page=5

最初の2つのルートをコメントアウトすると、正しいリンクが使用されます。will_paginateがデフォルトで最初のルートになるのはなぜですか?

4

2 に答える 2

2

ルートの順序をに変更します

get '/profile/:slug/instagram' => 'talents#show', :as => :talent_instagram
get '/profile/:slug/bio' => 'talents#show', :as => :talent_bio
get '/profile/:slug' => 'talents#show', :as => :talent

ルートは指定された順序で一致するためです。

于 2012-10-26T05:05:34.317 に答える
0

これが正解かどうかはわかりませんが、これはRailswill_paginateカスタムルートに役立つ可能性があります

于 2012-10-25T19:30:30.133 に答える