Will_Paginate NoMethodError(未定义的方法`paginate'

时间:2015-11-06 19:01:36

标签: ruby-on-rails ruby heroku

我试图进入" will_paginate"但是,当我将它推送到Heroku时,我在Heroku服务器上收到以下错误消息。该解决方案在我的环境开发中非常有效。

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]: 

帐户管理员:

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

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

宝石文件  来源&#39; http://rubygems.org&#39;

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

然后两个服务器上的gem env是相同的。我不确定问题是什么。

1 个答案:

答案 0 :(得分:0)

gem 'will_paginate', '~> 3.0'移除group :development, :test dogem 'will_paginate', '~> 3.0', group: :production,并更正了Heroku日志中的NoMethodError消息。