2010-05-12 88 views
1
我使用的是將分頁寶石從 http://github.com/mislav/will_paginate

will_paginate鏈接嵌套資源

路線

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

柱控制器:

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

我的問題就出在視圖:

<%= will_paginate @comments %> 

這會產生像//1頁→帖子的鏈接= 1
我需要的是/後/ 1 /評論?頁= 1

有沒有辦法直接告訴will_paginate使用什麼網址助手? (如post_comments_path

任何想法?

回答

1

checking the documentation?將:param選項傳遞給will_paginate,您可以在其中指定:controller等等。

+0

好吧,找到我自己的解決方案。 我知道了:params選項,但我被卡住的命名路線,我沒有想過通過:post_id與控制器和行動,以便它再次匹配路線..... 嗯,我想我應該從不開始編程,不要先喝咖啡,先問問一個愚蠢的問題。 – user284384 2010-05-12 13:30:56

+0

對不起,相當苛刻的答案 - 也沒有我的咖啡。 – 2010-05-12 14:31:39

+0

文檔沒有提到嵌套路由 – s84 2010-10-24 15:26:58