ruby - Rails pagination displaying wrong number of output -
in rails application, want order @students
latest assignment date. point noted
it's not necessary every student should have assignment on same date or that. means student can have assignment @ date.
the code of controller is:
@section = current_user.section @students = @section.students.includes(:assignments).order('assignments.assignment_date asc').paginate :page => params[:page], :per_page => 10
the problem is, in view, there 10 students in list, 6 items etc. mean random between 1 10. there should wrong in logic. please me resolve issue.
update:
i found there nothing wrong pagination. problem is, @section.students.includes(:assignments)
fetching duplicate student_id
being eliminated.
you can try below.
@section = current_user.section @students = @section.students.includes(:assignments).order('assignments.assignment_date asc').paginate( :page => params[:page], :per_page => 10)
Comments
Post a Comment