ruby on rails - undefined method `total_pages' for #<Tuto::ActiveRecord_Relation:0x007fc3b2473d80> -


i found couple of similar cases nothing fix problem...

i using gem kaminari paginate app.

since added it, researches failing , retrun error undefined method total_pages' #<tuto::activerecord_relation:0x007fc3b2473d80>

i have private method in tutos controller filter tutos

 def filter_tutos   return if params[:query].blank?   @tutos = tuto.search(params[:query][:keyword]).includes(:user, :category) if params[:query][:keyword].present?   @tutos = tuto.joins(:user).where('users.nickname ?', params[:query][:user]) if params[:query][:user].present?   @tutos = tuto.joins(:category).where('categories.name ?', params[:query][:category]) if params[:query][:category].present?  end 

index method in tutos controller :

  def index     filter_tutos if params[:query].present?     @tutos ||= tuto.all.page params[:page]   end 

in view have:

  .pagination       = paginate @tutos 

i added paginates_per 5 in tuto model

try this. pagination not called on @tutos. if blank tuto objects paginated not otherwise.

  def index     filter_tutos if params[:query].present?     @tutos = @tutos.count > 0 ? @tutos : tuto.all     @tutos = @tutos.page params[:page]   end 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -