Sql 尽管需要';将分页/数组';?

Sql 尽管需要';将分页/数组';?,sql,ruby-on-rails,ruby,postgresql,will-paginate,Sql,Ruby On Rails,Ruby,Postgresql,Will Paginate,我有一个搜索模型,它构造了一个基本上是原始SQL的字符串。此字符串通过find_by_sql调用运行,并返回到下面第5行的控制器(@search.query请参阅本文: 所以对于你的控制器,它看起来是这样的 def roster_builder require 'will_paginate/array' authorize! :access_roster_builder, current_coach @search = Search.new(sport: current_coac

我有一个搜索模型,它构造了一个基本上是原始SQL的字符串。此字符串通过find_by_sql调用运行,并返回到下面第5行的控制器(@search.query请参阅本文:

所以对于你的控制器,它看起来是这样的

def roster_builder
    require 'will_paginate/array'
  authorize! :access_roster_builder, current_coach
  @search = Search.new(sport: current_coach.primary_sport, conditions: params[:search])

  # @athletes = @search.query.page(params[:page]).per_page(8)
    @athletes = @search.query.paginate page: params[:page], per_page: 8

  if params[:refresh]
    render "athletes_refresh" 
  else
    render "athletes" if request.format.js?
  end
end
NoMethodError (undefined method `page' for #<Array:0x00000105b7add0>)
require 'will_paginate/array'
def roster_builder
    require 'will_paginate/array'
  authorize! :access_roster_builder, current_coach
  @search = Search.new(sport: current_coach.primary_sport, conditions: params[:search])

  # @athletes = @search.query.page(params[:page]).per_page(8)
    @athletes = @search.query.paginate page: params[:page], per_page: 8

  if params[:refresh]
    render "athletes_refresh" 
  else
    render "athletes" if request.format.js?
  end
end