简体   繁体   English

Will_Paginate NoMethodError(未定义方法`paginate'

[英]Will_Paginate NoMethodError (undefined method `paginate'

I'm trying to in the "will_paginate" gem however when I push it to Heroku, I get the following error message on the Heroku server. 我正在尝试放入“ will_paginate” gem,但是当我将其推送到Heroku时,我在Heroku服务器上收到以下错误消息。 The solution works perfectly in my development in environment. 该解决方案非常适合我在环境中的开发。

2015-11-06T18:34:43.422821+00:00 app[web.1]: Processing by AccountsController#index as HTML
        2015-11-06T18:34:43.509289+00:00 app[web.1]: 
        2015-11-06T18:34:43.509292+00:00 app[web.1]: NoMethodError (undefined method `paginate' for #<Account::ActiveRecord_Relation:0x007f39bc853bd8>):
        2015-11-06T18:34:43.509293+00:00 app[web.1]:   app/controllers/accounts_controller.rb:8:in `index'
        2015-11-06T18:34:43.509294+00:00 app[web.1]: 
        2015-11-06T18:34:43.509295+00:00 app[web.1]: 

Accounts Controller: 客户控制器:

class AccountsController < ApplicationController
  before_action :authenticate_user!
  before_action :set_account, only: [:show, :edit, :update, :destroy]

  respond_to :html

  def index
    @account = Account.all.order("created_at DESC").paginate(:page => params[:page], :per_page => 8)
  end

  def show
    @notes = Note.where(account_id: @account.id) #Where a note belong to the current account
  end

  def new
    @account = Account.new
    respond_with(@account)
  end

  def edit
  end

  def create
    @account = Account.new(account_params)
    @account.save
    respond_with(@account)
  end

  def update
    @account.update(account_params)
    respond_with(@account)
  end

  def destroy
    @account.destroy
    respond_with(@account)
  end

  private
    def set_account
      @account = Account.find(params[:id])
    end

    def account_params
      params.require(:account).permit(:first_name, :last_name, :return_client, :program_id, :insurance_id, :address, :phone)
    end
end

Index.html.erb Index.html.erb

<br>
<%= will_paginate @account , renderer: BootstrapPagination::Rails %>
<br>
<%= link_to 'Add Client', new_account_path %>

Gem File source ' http://rubygems.org ' 宝石文件来源' http://rubygems.org '

ruby '2.1.5'
gem 'rails', '4.1.8'
gem 'sqlite3', group: :development
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc
gem 'rails_12factor', group: :production
gem 'pg', group: :production
gem 'carrierwave'
gem "fog"
gem "figaro"
gem 'tzinfo-data', platforms: [:mingw, :mswin]
gem 'execjs'
gem "mini_magick"
gem 'devise'
gem 'searchkick'
group :development, :test do
  gem 'rspec-rails', '~> 3.0'
  gem 'will_paginate', '~> 3.0'
  gem 'will_paginate-bootstrap'
end

Then gem env is the same on both servers. 然后gem env在两个服务器上都相同。 I'm not sure what the problem is. 我不确定是什么问题。

除去gem 'will_paginate', '~> 3.0'group :development, :test dogem 'will_paginate', '~> 3.0', group: :production并且在Heroku的日志校正的NoMethodError消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM