When using find_all_by_completed (false), the page ordering does not work,

In my project model

def incomplete @clients = current_user.clients.find_all_by_completed(false).paginate (:page => params[:page], :per_page => 10, :order => 'started_on DESC') end 

For some reason, it doesn't order start_on downstream. However, the procedure in another method

 def all @clients = current_user.clients.paginate(:page => params[:page], :per_page => 25, :order => 'started_on DESC') end 

So, I assume that using find_all_by_completed discards paginate. I am using will-paginate btw. Any help?

+4
source share
1 answer

Try to fulfill the condition explicitly:

 @clients = current_user.clients.paginate( :conditions => {:completed => false}, :page => params[:page], :per_page => 10, :order => 'started_on DESC') 
+4
source

Source: https://habr.com/ru/post/1299069/


All Articles