Reputation: 3040
We're using will_paginate to display associations of a model. We have some custom routes set up like so:
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
When we're using talent_instagram route, all pagination links are rendered to the default route instead. That is, instead of:
http:://0.0.0.0:3000/profile/some-talent/instagram?page=5
This is what we get:
http:://0.0.0.0:3000/profile/some-talent?page=5
If I comment out the first two routes, then the correct link is used. Why is will_paginate defaulting to the first route?
Upvotes: 1
Views: 756
Reputation: 1534
Change the order of the routes to
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
because routes are matched in the order they are specified!
Upvotes: 2
Reputation: 41864
Not sure if this is the correct answer or not, but this may help you Rails will_paginate custom route
Upvotes: 0