I'm trying to get will paginate to link to my nested route instead of the regular posts variable. I know I'm supposed to pass some params to paginate but I don't know how to pass them.
Basically there is an array stored in @posts
and the other param paginate has access to is category_id
.
The nested route is /category/1/posts
but hitting next and previous on will paginate returns a url like this posts?page=1&category_id=7
.
<%= will_paginate @most_recent_posts "What do I do here?" %>
This is the result of Yannis's answer:
In your controller you can do:
@posts = @category.posts.paginate
And in your view:
<%= will_paginate(@post) %>
Doing this comes up with the following URL
posts?page=2&post_category_id=athlete_management
routes.rb #there are more routes but these are the relevant ones
map.resources :posts
map.resources :post_categories, :has_many => :posts