我想與我的rails應用程序中的will_paginate分頁。麻煩與分頁(will_paginate)
在我的控制器我有
def index
params[:per_page] ||= 25
params[:page] ||= 1
@links = Link.order('created_at DESC').page(params[:page]).per_page(params[:per_page])
end
在我看來,我有
<ul>
<% @links.each do |entry| %>
<li><%= link_to entry.title, entry.url %></li>
<% end %>
<ul>
<%= will_paginate @links %>
,我發現了錯誤
comparison of Fixnum with String failed
Extracted source (around line #8):
5: </h2>
6:
7: <ul>
8: <% @links.each do |entry| %>
9: <li><%= link_to entry.title, entry.url %></li>
10: <% end %>
11: <ul>
我不知道爲什麼。我試過重新啓動服務器。我錯過了明顯的東西嗎?
在此先感謝。
你確定錯誤在你的分頁上嗎?在哪一行發生了錯誤?你能跟蹤代碼中的位置嗎? – MurifoX 2013-04-26 17:32:57
我已將錯誤添加到我的問題中 – JacobSDK 2013-04-26 17:37:28
您是否在'params'中有':page'和':per_page'或者您獲得了默認值? – 2013-04-26 17:41:30