views:

111

answers:

1

Hi, 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?

A: 

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

Jakub Hampl
Ok, found my own solution.I knew about :params option but I was to stuck with named routes that I didn't thought about passing :post_id with the controller and action so that it matches the route again.....Well, I guess I should never start programming without having coffee first, sry for asking a stupid question.
Sorry for the rather harsh answer - didn't have my coffee either.
Jakub Hampl
THe documentation does not mention nested routing
Sam