user284384
user284384

Reputation: 13

will_paginate link to nested resources

I'm using the will paginate gem from http://github.com/mislav/will_paginate

Routes:

map.resources :post do |post|
  post.resources :comments
end

Post Controller:

@post = Post.first
@comments = @post.comments.paginate :page => params[:page], :per_page => 10

My problem lies in the view:

<%= will_paginate @comments %>

This generates links like /post/1?page=1
What I need is /post/1/comments?page=1

Is there a way to just tell will_paginate what url helper to use? (like post_comments_path)

Any ideas?

Upvotes: 1

Views: 953

Answers (1)

Jakub Hampl
Jakub Hampl

Reputation: 40573

How about checking the documentation? Pass the :param option to will_paginate where you can specify things like :controller and so on.

Upvotes: 1

Related Questions