J'ai quelques nouvelles actions pour le modèle de notification et les choses ont commencé à être en désordre donc j'ai refactorisé de <% = render @other_notifications %>
avec notifcations/_notification.html.erb
à la structure suivante.rails will_paginate avec différents partiels
Mon problème est le suivant. La page rend tout bien, mais la pagination ne fonctionne pas correctement. Donc SI j'ai la structure ci-dessous et ne supprime pas _notification.html.erb
alors la page sera chargée avec les nouveaux partiels d'action et les objets de pagination seront chargés avec _notification.html.erb
. SI je supprime _notification.html.erb
alors la page charge encore avec les nouveaux partiels, mais la pagination ne fonctionne pas. Comment devrais-je changer la pagination pour que cela fonctionne?
notifications_controller.rb
def other_notifications
@other_notifications = current_user.notifications.not_chat.order(created_at: :desc).includes(:sender_profile).
paginate(page: params[:page], per_page: Notification.pagination_per_page)
current_user.reset_new_other_notifications
respond_to do |format|
format.html
format.js
end
end
other_notifications.html.erb
<div class = "other-notifications-index">
<% @other_notifications.each do |notification| %>
<% if lookup_context.template_exists?(notification.action, "notifications/actions", true) %>
<%= render partial: "notifications/actions/#{notification.action}", locals: { notification: notification } %>
<% end %>
<% end %>
</div>
<div id="infinite-othernotification-scrolling">
<%= will_paginate @other_notifications %>
</div>
other_notifications.js.erb
$('.other-notifications-index').append('<%= j render @other_notifications %>');
<% if @other_notifications.next_page %>
$('.pagination').replaceWith('<%= j will_paginate @other_notifications %>');
<% else %>
$(window).off('scroll');
$('.pagination').remove();
$('.no-more').delay(1000).fadeIn(1500);
<% end %>