Ruby on rails 将分页生产命名错误(未定义[]:ActiveRecord::Relation的“page”方法):

Ruby on rails 将分页生产命名错误(未定义[]:ActiveRecord::Relation的“page”方法):,ruby-on-rails,capistrano,will-paginate,Ruby On Rails,Capistrano,Will Paginate,我正在使用will_paginate gem for ajax,如查看更多链接。它在开发中有效,但在生产中失败 在我的生产日志中,我得到: NoMethodError (undefined method `page' for []:ActiveRecord::Relation): 我已尝试在生产应用程序的根目录中键入: grep will_paginate Gemfile.lock 并获得: will_paginate (3.0.4) will_paginate cap bundle:in

我正在使用will_paginate gem for ajax,如查看更多链接。它在开发中有效,但在生产中失败

在我的生产日志中,我得到:

NoMethodError (undefined method `page' for []:ActiveRecord::Relation):
我已尝试在生产应用程序的根目录中键入:

grep will_paginate Gemfile.lock
并获得:

will_paginate (3.0.4)
will_paginate
cap bundle:install don’t fails在我的VPS上安装will_paginate,但当我试图明确要求“will_paginate”it steel works处于开发阶段且在生产中失败时,但这一次整个站点,不仅仅是我使用的操作将进行paginate。这在unicorn.log中触发了一个错误:

No such file to load will_paginate (LoadError)
因此,我认为will_paginate不会通过捆绑安装在我的VPS上正确安装他的目录,但为什么呢

我试着键入:

gem list
在那里,没有人会去寻欢作乐。因此,我明确地在我当前的应用程序目录中。 gem安装将进行分页 这也没有解决问题

所以我 gem卸载将进行分页 然后再次部署cap 在我再次 宝石清单 又一次,在那里,没有人会

档案: deploy.rb 结束

有人能帮我解决这个问题吗

或者可能有人知道如何将will_paginate所需的所有文件显式添加到rails应用程序。?因此,它将在没有宝石的情况下工作

我认为:

bundle exec gem list

在列表中,查找将分页为3.0.4。这意味着它已安装,但不是为我的应用程序安装的?

漫长的不眠之夜终于结束了。配方是:

gem update --system (on both: server and local machine)
将本地ruby版本更新为服务器上的ruby版本,反之亦然

cap deploy:setup (don't now if it is necessary, but it works for me)
cap deploy && cap deploy:restart
砰,它起作用了

问题出在ruby版本中。它们是不同的本地/远程机器


您可以在这里找到Mislav回答的问题:

您能给出用于部署的cap脚本吗?好的。我把它添加到我的问题中
gem update --system (on both: server and local machine)
cap deploy:setup (don't now if it is necessary, but it works for me)
cap deploy && cap deploy:restart