分页问题:`map' :未定义的方法'存在'

时间:2016-10-21 07:29:36

标签: ruby-on-rails rubygems

我刚刚安装了import freemarker.template.Configuration; import freemarker.template.Template; import java.io.StringWriter; import java.util.HashMap; import java.util.Map; public class Main { public static void main(String[] args) { System.out.println("Hello World!"); Configuration configuration = new Configuration(); try { Template helloTemplate = configuration.getTemplate("hello.html"); StringWriter writer = new StringWriter(); Map<String, Object> helloMap = new HashMap<String, Object>(); helloMap.put("name", "Freemark"); helloTemplate.process(helloMap, writer); System.out.println(writer); } catch (Exception e) { e.printStackTrace(); } } } will_paginate, 3.0.7 gem,当我调用以下内容以使我的文章分页时

bootstrap-will_paginate, 0.0.10

尝试启动localhost服务器时出现以下错误

def index
 @articles = Article.paginate(page: params[:page], per_page: 5)
end

出了什么问题?

1 个答案:

答案 0 :(得分:8)

这是早期版本的will_paginate与Rails 5的问题。

您需要更新will_paginate gem以使用最新更新的gem:

gem 'will_paginate', '3.1.5'

此问题已通过此合并修复: https://github.com/mislav/will_paginate/pull/450