[英]Rails 4 - will_paginate
This is my first attempt using will_paginate (I know! Where have I been??) 这是我第一次尝试使用will_paginate(我知道!我去过哪里了?)
titles_controller.erb titles_controller.erb
def index
@titles = Title.active.sorted.paginate(:page => params[:page])
end
index.html.erb index.html.erb
<% will_paginate @titles.each do |title| %>
Error: 错误:
undefined method `total_pages' for #<Enumerator:0x00000002bacaf0>
WTF am I doing wrong? WTF我做错了吗? Thanks in advance.
提前致谢。
In your case you dont acctually need to write: 在你的情况下,你不需要写:
<%= will_paginate @titles %>
Because it is in the context of the title_controller, will_paginate will assume their is a @titles variable available. 因为它位于title_controller的上下文中,所以will_paginate将假设它们是一个可用的@titles变量。 Thus it is possible to just write:
因此可以写:
<%= will_paginate %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.