will paginate - Rails will_paginate on two objects on the same page does not work -


i have seen similar asked before, can not understand it, , can not ask there because of low reputation comment.

so, asking new question. using will_paginate plug in 2 objects on same page, , working both move simultaneously. example, if click page 2 on first, page 2 changes in second pagination.

this code in controller:

    @tasks = @student.tasks.paginate(page: params[:page], :per_page => 2)     @plans = @student.plans.paginate(page: params[:page], :per_page => 2)          

and code in view:

    <%= will_paginate @tasks %>     <%= will_paginate @plans %> 

how can make work separately?

your controller using same parameter :page each model. view uses parameter set page both models in view. can define different parameter work each model. ie.

@tasks = @student.tasks.paginate(page: params[:tasks_page], :per_page => 2) @plans = @student.plans.paginate(page: params[:plans_page], :per_page => 2)           <%= will_paginate @tasks, :param_name => 'tasks_page'%> <%= will_paginate @plans, :param_name => 'plans_page'%> 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -