will_paginate with search function is not working in ruby on rails -


i trying search posts item pagination. doing this..

@posts = post.search(params[:search]).paginate(page: params[:page],:per_page => 5) 

but showing nomethoderror

undefined method `paginate' #<array:0x9a93f08> 

i don't know wrong. please help

i change code

@posts = post.search(params[:search]).paginate(page: params[:page],:per_page => 5) 

to this

@posts = post.paginate(page: params[:page],:per_page => 5).search(params[:search]) 

now works fine :)


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -