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

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -