ruby on rails 4 - Kaminari : undefined method total_pages -


i have problem on kaminari rails 4.

here renters_controller.rb

def search   @location = params[:search]   @distance = params[:km]   @renters = renter.near(@location, 30000).order("distance")   @renters = @renters.page(params[:page])    if @renters.empty?     @renters = renter.all     search_map(@renters)   else     search_map(@renters)   end end 

and view search.html.haml.

.row   = paginate @renters 

and error message

started "/search?utf8=%e2%9c%93&search=" ::1 @ 2016-03-17 09:37:59 +0100 processing renterscontroller#search html parameters: {"utf8"=>"✓", "search"=>""} (0.5ms)  select count(count_column) (select  1 count_column "renters" (false) limit 25 offset 0) subquery_for_count renter load (0.9ms)  select "renters".* "renters" rendered renters/search.html.haml within layouts/application (8.2ms) completed 500 internal server error in 23ms (activerecord: 1.5ms)  actionview::template::error (undefined method `total_pages' #<renter::activerecord_relation:0x007fd4d36bdc30>): 1: .row 2:   = paginate @renters app/views/renters/search.html.haml:2:in `_app_views_renters_search_html_haml__3667517883215455359_70276042599600' 

in controller, works if write

@renters = renter.page(params[:page]) 

any idea ?

try this, hope work.

def search   @location = params[:search]   @distance = params[:km]   @renters = renter.near(@location, 30000).order("distance")    if @renters.empty?     @renters = renter.all     search_map(@renters)   else     search_map(@renters)   end   @renters = @renters.page(params[:page]) end 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -